Why don't input elements display the value passed to ASP.Net MVC?

This post asks this question, but doesn’t really give an answer, so I decided to ask the question differently.

I have a page that displays a hidden value from a model:

<%=Html.Hidden("myName", model.myValue) %>

Since I pass the value in the value parameter, you think that it will output that value, but it is not.

The code for the render input fields has the following:

string attemptedValue = (string)htmlHelper.GetModelStateValue(name, typeof(string));
tagBuilder.MergeAttribute("value", attemptedValue ?? ((useViewData) ? htmlHelper.EvalString(name) : valueParameter), isExplicitValue);

Basically, if a ModelState (containing published values) contains the value of the passed “name”, it will use that value instead of the passed value for the helper method. In my case, I updated the model and my updated value was not output.

If I pass a value to a method, I expect that value to be displayed.

- ?

+3
1

. :

  • URI.
  • .
  • . ModelState , , Html.Hidden. , Html.TextBox("someName", Model.SomeValue)
  • , . , POST, , , - .

, POST, ViewResult, 3 . , ( ) . , , , , Model.SomeValue - . Model.SomeValue integer, , "ABC", - - . "- " - ModelState.

.

+2

Source: https://habr.com/ru/post/1737692/


All Articles