• 自定义Image HtmlHelper


            public static void Image(this HtmlHelper helper, string src, string alt = null, object htmlAttributes = null)
            {
                System.Web.UI.HtmlTextWriter writer = new HtmlTextWriter(helper.ViewContext.HttpContext.Response.Output);
                System.Web.Mvc.TagBuilder tbImage = new TagBuilder("img");
    
                tbImage.MergeAttribute("src", src);
                tbImage.MergeAttribute("alt", alt);
                if (htmlAttributes != null)
                {
                    tbImage.MergeAttributes<string, object>(new RouteValueDictionary(htmlAttributes));
                }
    
                writer.InnerWriter.Write(tbImage.ToString(TagRenderMode.SelfClosing));
            }
  • 相关阅读:
    COM组件
    【游戏引擎架构】入门(一)
    UNICODE字符串
    Python随笔10
    Python随笔9-函数
    Python随笔7
    Python随笔6
    Python随笔5
    Python随笔4
    Python随笔3
  • 原文地址:https://www.cnblogs.com/freeliver54/p/3964536.html
Copyright © 2020-2023  润新知