Persist SelectList in model on Post

前端 未结 2 1174
臣服心动
臣服心动 2020-12-11 17:13

In MVC4:

I have the following property in my model used for a dropdown list:

public SelectList Subjects { get; set; }

I set the Sub

2条回答
  •  执念已碎
    2020-12-11 17:53

    Browsers only post back the selected values on the form elements. Also, its not a good idea to post back the values which can be retrieved from the data store. You would have to pull the items in the list just like you did while populating the list.

    Also, MVC does not maintain the state of the page like .NET webpages as it does not have a view state. Developers are fully responsible for managing states of pages between the post backs, which is the essence of MVC design pattern.

提交回复
热议问题