asp.net – Html.BeginForm()类型的扩展名
发布时间:2020-08-04 20:09:39 所属栏目:asp.Net 来源:互联网
导读:有没有人知道创建自定义 HtmlHelperextension方法的语法,其行为类似于.. % using (Html.BeginForm()) {%pLoads of html stuff here /p% } % 我正在考虑…… 有任何想法吗? 干杯, ETFairfax 您需要创建一个实现IDisposable接口的类,并从HtmlHelper返回该接口.
|
有没有人知道创建自定义 HtmlHelperextension方法的语法,其行为类似于.. <% using (Html.BeginForm()) {%>
<p>Loads of html stuff here </p>
<% } %>
我正在考虑…… 有任何想法吗? 干杯, ETFairfax 解决方法您需要创建一个实现IDisposable接口的类,并从HtmlHelper返回该接口.public static class HtmlHelperTableExtensions {
private class TableRenderer : IDisposable {
HtmlHelper html;
public TableRenderer(HtmlHelper html) {
this.html = html;
}
public void Dispose() {
HtmlHelperTableExtensions.EndTable(html);
}
}
public static IDisposable BeginTable(this HtmlHelper html) {
// print begin table here...
return new TableRenderer(html);
}
public static void EndTable(this HtmlHelper html) {
// print end table here...
}
} (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Asp.net实现MVC处理文件的上传下载功能实例教程
- asp.net – Orchard CMS Media中的文件大小上传限制
- asp.net-mvc – 何时使用asp.net mvc的路由规则vs查询字符串
- asp.net – 在剃刀中等同于End / Response.End?
- asp.net-mvc – 为什么DropDownListFor会在提交后丢失多个选
- asp.net – 将web应用程序的项目编译成dll
- asp.net – GetExternalLoginInfoAsync()loginInfo返回null
- asp.net-web-api – WebAPI中的长时间运行任务
- 如何在ASP.NET MVC中配置3个级别的URL?
- asp.net – .NET Web API 2 OWIN承载令牌认证
推荐文章
站长推荐
- asp.net-mvc – 如何在ASP.NET MVC中传递页面的元
- asp.net-mvc-3 – 局部视图中的RenderSection
- asp.net – Razor base type / Templated Razor使
- asp.net-mvc – 是否有一个ASP MVC与JSTL标签等效
- asp.net-mvc-3 – DropDownListFor Unobtrusive
- 如何合理地构建我的ASP.NET MVC 2项目与区域
- asp.net – 防止XSS(跨站脚本)
- asp.net – DirectoryServicesCOMException 8007
- ASP.NET MVC删除操作方法中的查询字符串
- asp.net-mvc – asp.net mvc – string或int的路
热点阅读
