MVC2:不可能改变与TextBoxFor的名字吗? [英] MVC2: Impossible to change the name with TextBoxFor?
本文介绍了MVC2:不可能改变与TextBoxFor的名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想手动定义编号和名称一样,文本框:
I want to manually define id and name for textbox like that:
<%: Html.TextBoxFor(model => model.Name, new { @id = "txt1", @name = "txt1" })%>
但只有ID被改变,而不是name属性,为什么?
But only the id is changed, not the name attribute, why?
<input id="txt1" name="Name" type="text" value="">
感谢您!
推荐答案
您不能使用强类型的lambda版本对于这一点,你需要使用旧版本的
You can't use the strongly typed lambda version for this, you'd need to use the older version
Html.TextBox("txt1",new {@id = "txt1"})
这篇关于MVC2:不可能改变与TextBoxFor的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文