I want to manually define id and name for textbox like that:
<%: Html.TextBoxFor(model => model.Name, new { @id = "txt1", @name = "txt1" })%>
But only the id is changed, not the name attribute, why?
<input id="txt1" name="Name" type="text" value="">
Thank you!
This is ok:
Do you write "Name" instead of "name"?
Output:
Actually you can... just use
Name
with first letter capitalized instead ofname
:You can't use the strongly typed lambda version for this, you'd need to use the older version
If you still need to use
TextBoxFor()
, you can change the name of the property on your model, which should be easy if you're using dedicated ViewModels as is recommended. However I admit it's a recommendation I don't always follow myself.