gpt4 book ai didi

vb.net - 为什么 不起作用?

转载 作者:行者123 更新时间:2023-12-02 07:23:49 25 4
gpt4 key购买 nike

据我了解,通过向类中的属性添加 ScaffoldColumn(false) 注释,在添加 View 时该属性不会添加到 View 中。然而,即使我已将 scaffoldcolumn false 添加到我不想添加到创建表单的属性,它们仍然呈现在创建 View 中。 ScaffoldColumn 是否损坏?在 Freeman 和 Sanderson 的 Pro ASP.NET MVC 3 Framework 第 552 页上,它指出

"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."

第 77 页上的 MVC Music Store PDF 也表明属性将执行相同的操作 -

"Allows hiding fields from editor forms".

他们将其添加到AlbumId 属性,然后当应用程序运行时AlbumId 字段不会显示在浏览器中。

这个属性有问题吗?

如果我将 html 帮助程序更改为 DisplayFor,无论是否存在脚手架列,它都不会出现在表单中。例如,我在Property PostTitle上没有scaffoldcolumn false,但是如果我将@Html.EditorFor(Function(model) model.PostTitle)更改为displayfor,那么无论什么情况它都不会渲染脚手架列属性。

此外,我的“创建” View 被强类型化为@ModelType RiderDesignMvcBlog.Core.Entities.Post

最佳答案

在 ASP.NET 论坛中收到此答案:

That statement is incorrect. The attribute is recognized by Dynamic Data, but not by MVC 3 Scaffolding. When I asked about this in March of this year, I got this response from the team that created the MvcScafolding Nuget package:

Yes, that particular bit of metadata just isn’t recognized by the MvcScaffolding T4 templates. There’s a lot of possible metadata, and a lot of code necessary to recognize and respond to it all, and we have to trade that off against keeping the T4 templates simple enough that people can understand and customize them and not be overwhelmed with all the logic. I don’t think the MVC 3 built-in Add View templates respond to that one either.

关于vb.net - 为什么 <ScaffoldColumn(False)> 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7626671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com