微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net-mvc-3 – MVC 3 Razor EditorTemplate / DisplayTemplate母版页

有没有人想出如何使用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 = "" })
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐