MVC5 Lost Value In Textbox After Submit
Solution 1:
What's a "postback"? It sounds like you're trying to think of this in terms of WebForms, where the server-side controls have a lot of plumbing doing things behind the scenes.
Simply put, there is no code in your view which actually puts a value in that input
. When using the HTML helpers, while the generated client-side markup is the same (and, thus, the post to the next controller action is the same), one thing that's different is that the HTML helpers will bind the control to the model that's supplied to the view.
HTML, by itself, won't do that. You can, however, do that manually:
<input value="@Model.LastName" class="form-control text-box single-line" id="LastName" name="LastName" style="width: 120px;" type="text">
^--- right here
Solution 2:
You need to add the textbox in your model, and the link it in the view index.cshtml like this: m = m.Variable_name_from_your_model
Check out this site: https://mvcstepbystep.wordpress.com/how-to-update-a-c-mvc-textbox-from-jquery/
Post a Comment for "MVC5 Lost Value In Textbox After Submit"