1
You can change the name of the field generated by @Html.TextBoxFor
? I found nothing in Portuguese related to this.
I tried something like:
@Html.TextBoxFor(x => x.ToDate, new { name = "to" })
If I do for example, for ID or Style:
@Html.TextBoxFor(x => x.ToDate, new { style = "display: none;", id = "to" })
Works for the two above, but not for the name.
So there is a way to change the name
generated by default by @Html.TextBoxFor
?
You can write a Html Helper for this but, if you change the name will not be possible to post the form, the
MVC
will not take the value of the field to theModel
, you don’t want that right? In that case it wouldn’t be easier to declare ainput
simple instead of using the HelperHtml.TextBoxFor
?– Ricardo Pontual
But my intention is not to use with the model, but with parameters, separate from the same model.
– LP. Gonçalves
So if you don’t want to use the model, why not use an element
html
then? Then you can put the name you want. The helper@Html.TextoBoxFor
is to be used thinking of Binding and model post onMVC
– Ricardo Pontual
I use a model in the view, for a form, but also another form that uses one or another data that is filled in the template, but not all model data.
– LP. Gonçalves