How to get the value of an @Html.Textboxfor to an Input? Asp.net mvc

Asked

Viewed 939 times

0

I want to take the value that is in @Html.Textboxfor is to add in the input

<div class="col-md-3 form-group">
<label>Multiplicador 01:</label>
<input class="form-control input-sm" autocomplete="off" value= @Html.TextBoxFor(c => Model.VALOR01) type="number" ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/" step="0.01" id="valor1" name="valor1">

2 answers

1

@itasouza, I believe that in this case you can use @Html.Editorfor, defining his type as number, would look like this:

@Html.EditorFor(Model => Model.VALOR01 , new { @type = "number", @id= "valor1", @step = "0.01", @name="valor1", @autocomplete="off"})

hope I’ve helped.

Abs

0

@Html.TextBoxFor() generates a new <input> for you. The correct thing is to take directly the value of the Model:

<input class="form-control input-sm" autocomplete="off" value="@Model.VALOR01" type="number" ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/" step="0.01" id="valor1" name="valor1">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.