Obtain the field value in the controller.

Source: Internet
Author: User

In ASP. net mvc, there are many methods to post data to the Controller. But what if we want to get the feild value in the controller? How to get it?
You can notice that there is a formcollection class. It helps us solve this problem.


Here is a simple example. In the ASP. net mvc application, create a sepcontroller Controller under the controllers directory. Now the exercises we did in July and July are all done under this controller.


Then, under the views directory, the corresponding controller creates the postdatatocontrol. cshtml view, in the View:



There is a text box and a submit button, which is used to post data to the Controller. OK, we also need to create another action in the controller:


See the results:


Obtain the field value in the controller.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.