ASP.NET MVC HTML辅助可以使没有ID属性的元素? [英] Can ASP.NET MVC html helpers render an element without an ID attribute?
问题描述
假设我要产生ASP.NET MVC 2类似于这样一个元素:
Assume I want to generate an element similar to this in ASP.NET MVC 2:
<%= Html.TextBoxFor(p => p.FooBar)%>
是否有过载或方式,我可以得到ASP.NET MVC 2只生成一个名称属性,而不是id属性?
我可以把它生成℃的空白标识;%= Html.TextBoxFor(P =&GT; p.FooBar,新{ID =})%&GT;
,但我想生成没有ID的元素可言,没有覆盖asp.net mvc框架。
I can have it generate a blank id with <%= Html.TextBoxFor(p => p.FooBar, new { id = "" })%>
, but I would like to generate the element with no ID at all, and without overriding the asp.net mvc framework.
推荐答案
在HTML佣工的行为已更改为MVC 2 RC1,以便通过新{ID =}
燮presses的标识的全部,而不是输出一个空的标识的属性。
The behavior of the HTML helpers was changed as of MVC 2 RC1 so that passing new { id = "" }
suppresses id entirely rather than outputting an empty id attribute.
这篇关于ASP.NET MVC HTML辅助可以使没有ID属性的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!