为什么不工作?
据我了解,通过向类中的属性添加 ScaffoldColumn(false) 注释,在添加视图时该属性不会添加到视图中。然而,即使我已将 scaffoldcolumn false 添加到我不想添加到创建表单的属性,它们仍然呈现在创建视图中。 ScaffoldColumn 是否损坏?在 Freeman 和 Sanderson 的 Pro ASP.NET MVC 3 Framework 第 552 页上,它指出
“如果我们想从生成的 HTML 中排除某个属性,我们可以使用 ScaffoldColumn 属性。当脚手架工看到 ScaffoldColumn 属性,它们完全跳过该属性;不 将生成隐藏的输入元素,并且没有详细信息 属性将包含在生成的 HTML 中。”
第 77 页上的 MVC Music Store PDF 也表明该属性将执行相同的操作 -
“允许隐藏编辑器表单中的字段”。
他们将其添加到 AlbumId 属性,然后当应用程序运行时,AlbumId 字段不会显示在浏览器中。
这个attr坏了吗?
如果我将 html 帮助程序更改为 DisplayFor,无论脚手架列是否存在,它都不会出现在表单中。例如,我在Property PostTitle上没有scaffoldcolumn false,但是如果我将@Html.EditorFor(Function(model) model.PostTitle)
更改为displayfor
,那么无论什么情况它都不会渲染脚手架列属性。
另外,我的 Create 视图被强类型化为 @ModelType RiderDesignMvcBlog.Core.Entities.Post
Its my understanding that by adding the ScaffoldColumn(false) annotation to an property in a class, that property will not added to the view when doing Add View. However even though i have added scaffoldcolumn false to properties i dont want added to a Create form, they are still rendered inthe create view. Is ScaffoldColumn broken? On page 552 in Pro ASP.NET MVC 3 Framework by Freeman and Sanderson, it states
"If we want to exclude a property from the generated HTML, we can use
ScaffoldColumn attribute. When the scaffolding helpers see the
ScaffoldColumn attribute, they skip over the property entirely; no
hidden input elements will be generated and no details of this
property will be included in the generated HTML."
Also the MVC Music Store PDF on p 77 indicates that the attrtibute will do the same -
"Allows hiding fields from editor forms".
They add it to the AlbumId property and then when the app is run AlbumId field is not shown in the browser.
Is this attr broken?
If i change a html helper to DisplayFor it does not appear in the form regardless of whether scaffoldcolumn is present. For example i dont have scaffoldcolumn false on Property PostTitle but if i change @Html.EditorFor(Function(model) model.PostTitle)
to displayfor
then it does not render regardless of the scaffoldcolumn attr.
Also my Create view is strongly typed to @ModelType RiderDesignMvcBlog.Core.Entities.Post
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 asp.net 论坛中收到这个答案:
Received this answer in the asp.net forums: