View in ASP.NET MVC Application

I read that viewstate does not exist in an asp.net MVC application. I am doing a model check. Now, if I have two text fields on my page, and I do a mandatory check for both of them in the model. This check is done on the server side with the click of a button. I will fill in one text box and click submit. It performs validation and returns a result that requires a second field. At this time, the value of the first text field is saved. So can you tell me how this text box retains value even after postback?

+3
source share
5 answers

The text box value is tied to the model value.

Model , (.. ) ModelState.

, -)

,

Dan

0

" ". .

  • HTML.
  • .
  • POST.
  • Controller.ModelState.
  • ModelState Errors, .
  • . , (1), , , , .
  • .

, , Html.TextBox("someName", someValue), someValue, ModelState "someName", ModelState. ( ), .

+9

ModelState. http-, ModelState html- (Html.Label, Html.Hidden, Html.TextBox).

  • Html.TextBox().
  • .
  • .
  • ModelState .
  • Html.TextBox(). ModelState , . , ModelState.
+2

. , ( ModelState) , , ModelState.

+1

,

-1

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


All Articles