如何添加和使用剃刀编辑器模板 [英] How to add and use a razor editor template

查看:96
本文介绍了如何添加和使用剃刀编辑器模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到有关如何将剃须刀编辑器模板合并到项目中的文档或样本.在另一个线程上的以下答案可能会解决我遇到的问题,但我不知道如何将其合并到我的项目中.毫无疑问,这很容易.

这是我不知道如何合并的解决方案: 输入类型日期的客户端验证不起作用

解决方案

此处是添加EditorTemplate的简短信息.简而言之-您必须在 Views/Shared 中创建目录 EditorTemplates ,并且应使用与要为其创建编辑器的模型相同的名称来创建视图./p>

请记住,以该模型的对象作为参数调用Html.EditorFor时,会使用模型的EditorTemplate.当然,您应该使用它们来提供编辑的可能性-如果要创建仅显示数据的内容,请使用相同的方法来创建DisplayTemplate(创建 DisplayTemplates 目录). DisplayTemplate是在Html.DisplayFor调用中呈现的,该模型的对象作为参数.

I have tried to find documentation or samples on how to incorporate razor editor templates into a project. the following answer on another thread may fix a problem I am having but I do not know how to incorporate it into my project. It is no doubt easy.

here is the solution I do not know how to incorporate: Client-side validation of input type date does not work

解决方案

Here is short info about adding EditorTemplate. In short words - you have to create directory EditorTemplates in Views/Shared and you should create a view with the same name as the model you want to create the editor for.

Remember that EditorTemplate for a model is used when calling Html.EditorFor with object of this model as argument. You should use them to provide editing possibilities, of course - if you want to create something that should only display data, use the same way to create DisplayTemplate (create DisplayTemplates directory). DisplayTemplate is rendered on Html.DisplayFor call with object of this model as argument.

这篇关于如何添加和使用剃刀编辑器模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆