加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – MVC 3 Razor EditorTemplate / DisplayTemplat

发布时间:2020-12-16 06:29:05 所属栏目:asp.Net 来源:网络整理
导读:有没有人想出如何使用Master Pages for Editor使用Razor的DisplayTemplates类似于Brad Wilson在此处记录的内容? http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-5-master-page-templates.html 谢谢 解决方法 这并没有像我原先想
有没有人想出如何使用Master Pages for Editor&使用Razor的DisplayTemplates类似于Brad Wilson在此处记录的内容?

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-5-master-page-templates.html

谢谢

解决方法

这并没有像我原先想象的那样复杂.

一个小小的免责声明:这不是一个完整的审查,只是一个简单的例子,只是为了让它工作.

这就是我做的:

?/查看/共享/ _TemplateMaster.cshtml

<div class="editor-label">
    <label for="@ViewData.ModelMetadata.PropertyName">@ViewData.ModelMetadata.GetDisplayName()</label>
</div>
<div class="editor-field">
    @RenderSection("DataContent")
</div>
<div>
    @Html.ValidationMessage("")
</div>

?/查看/共享/ EditorTemplates / String.cshtml

@{
    Layout = "~/Views/Shared/_TemplateMaster.cshtml";
}

@section DataContent
{
    @Html.TextBox("",ViewData.TemplateInfo.FormattedModelValue,new { @class = "" })
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读