asp.net-mvc – 自定义EditorTemplate可以为其中的相同模型调用
发布时间:2020-12-16 09:46:30 所属栏目:asp.Net 来源:网络整理
导读:自定义EditorTemplate可以为其中的同一模型调用默认的EditorTemplate吗?同样适用于DisplayTemplates.这是一个简化的例子.在渲染LabelForModel时,不会渲染DisplayForModel或EditorForModel. 视图 div class="highlight1" @Html.DisplayFor(m = m.NullablePro
自定义EditorTemplate可以为其中的同一模型调用默认的EditorTemplate吗?同样适用于DisplayTemplates.这是一个简化的例子.在渲染LabelForModel时,不会渲染DisplayForModel或EditorForModel.
视图 <div class="highlight1"> @Html.DisplayFor(m => m.NullableProp,"NullableIntType1View") </div> <div class="highlight2"> @Html.EditorFor(m => m.NullableProp,"NullableIntType1View") </div> <div class="highlight1"> @Html.DisplayFor(m => m.NullableProp,"NullableIntType2View") </div> <div class="highlight2"> @Html.EditorFor(m => m.NullableProp,"NullableIntType2View") </div> 共享/ DisplayTemplates / NullableIntType1.cshtml @model System.Int32? This is display for NullableIntType1 <hr /> --> @Html.EditorForModel() <-- <hr /> --> @Html.DisplayForModel() <-- <hr /> --> @Html.LabelForModel() <-- 共享/ EditorTemplates / NullableIntType1.cshtml @model System.Int32? This is editor for NullableIntType1 <hr /> --> @Html.EditorForModel() <-- <hr /> --> @Html.DisplayForModel() <-- <hr /> --> @Html.LabelForModel() <-- 共享/ DisplayTemplates / NullableIntType2.cshtml @model System.Int32? This is display for NullableIntType2 <hr /> --> @Html.EditorForModel() <-- <hr /> --> @Html.DisplayForModel() <-- <hr /> --> @Html.LabelForModel() <-- 共享/ EditorTemplates / NullableIntType2.cshtml @model System.Int32? This is editor for NullableIntType2 <hr /> --> @Html.EditorForModel() <-- <hr /> --> @Html.DisplayForModel() <-- <hr /> --> @Html.LabelForModel() <-- 解决方法
asp.net MVC
Cannot be nested中的显示和编辑模板更糟糕的是,执行时,它们只是默默地失败.我认为这是设计模式的巨大限制,也是实施的巨大弱点.当它发挥作用时,它就像魔术一样,但是当它不起作用时,它确实是一个调试的熊.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-4 – 如何配置使用Authorize(Roles)属性时会发
- asp.net – 在网站项目中使用SignalR
- asp.net-mvc – 如何在asp.net core mvc中配置确认电子邮件
- asp.net – 引用依赖于ConfigurationManager的.net core 2中
- asp.net-mvc – 将ASP.NET MVC路由迁移到ASP.NET vNext
- asp.net – 如何解码RDP服务器的远程资源URL(webfeed.aspx)
- asp.net-mvc – 禁用客户端缓存
- 在ASP.NET Razor中格式化字符串
- asp.net-mvc – 在ASP.NET MVC中保留非表单模型数据
- 如果复选框被选中,ASP.NET – 需要一个文本框
推荐文章
站长推荐
- asp.net-mvc – 如何从MVC WEB API Controller返
- nuget-package – MvcScaffolding是否通过命令行
- asp.net – 得墨忒耳定律和OOP混淆
- asp.net – 如何防止重复的回发混淆我的业务层
- asp.net-mvc-4 – MVC4如何设置cookie然后重定向
- asp.net-mvc – json.net中哪个命名空间有JObjec
- asp.net – 获取客户端隐藏字段的值
- 如何从命令行自动“运行asp.net网站”?
- asp.net – 为什么Request.Cookies在foreach循环
- asp.net – 我可以在MasterPage中使用UpdatePane
热点阅读