Asp.net MVC标签 [英] Asp.net MVC Label For
本文介绍了Asp.net MVC标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下
<标签=用的名字>用名字< /标签>
&所述;%= Html.TextBoxFor(M => m.Customer.Name.Forename)%GT;
与此问题是,这将呈现为
<标签=用的名字>用名字< /标签>
<输入类型=文本值=NAME =Customer.Name.ForenameID =Customer_Name_Forename>
不是我想要的OFC。
我想延期正确渲染标签(即用for =具有输入id的值属性),是否有在MVC 2东西之前,我去写我自己的扩展,这是否nativly <? / p>
解决方案
&LT;%= Html.LabelFor(M =&GT ; m.Customer.Name.Forename)%GT;
&所述;%= Html.TextBoxFor(M =&GT; m.Customer.Name.Forename)%GT;
I have the following
<label for="Forename">Forename</label>
<%= Html.TextBoxFor(m => m.Customer.Name.Forename) %>
the problem with this is that this is rendered as
<label for="Forename">Forename</label>
<input type="text" value="" name="Customer.Name.Forename" id="Customer_Name_Forename">
not what I want ofc.
I would like an extension to render the label correctly (i.e. with the for="" attribute having the value of the input id), is there anything in MVC 2 that does this nativly before I go writing my own extension?
解决方案
<%= Html.LabelFor(m => m.Customer.Name.Forename) %>
<%= Html.TextBoxFor(m => m.Customer.Name.Forename) %>
这篇关于Asp.net MVC标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文