前言 HtmlHelper方法为我们提供很多html标签,只需在页面调用就行了,但是微软并没有把所有的html标签都对应有了扩展方法,需要我们重新自定义Htmlper,来满足我们需要。方法using System;using System.Collections.G ...
前言
HtmlHelper方法为我们提供很多html标签,只需在页面调用就行了,但是微软并没有把所有的html标签都对应有了扩展方法,需要我们重新自定义Htmlper,来满足我们需要。
方法
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace TestMvcHelper{ public static class HtmlExtensions { public static MvcHtmlString Submit(this HtmlHelper helper, get='_blank'>string value) { var builder = new TagBuilder("input"); //使我们创建的标签名字设为input builder.MergeAttribute("type", "submit"); //添加属性 type="submit" builder.MergeAttribute("value", value); return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing)); } }}
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:ASP.NET MVC 之自定义HtmlHelper
关键词:ASP.NET
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。