In ASP. net mvc, the backend transmits multiple objects (tables) to the foreground.

Source: Internet
Author: User

Those who have used the Asp.net MVC label know that this label is very convenient. They do not need to assign values to JS, but are directly bound to ASP. net mvc labels. The premise is that the background method must return a page, that is, return view ("~ /Controller/View "). Of course, this method also has its limitations, rather than void and other types of methods. This MVC tag binding method is generally used when a large number of background database fields need to be received on the front-end page, such as personal information and enterprise information. In general, a small amount of data can be directly requested using Ajax.

In the ASP. net mvc background, you need to return an object

That is:

Public actionresult getinfo ()

{

Myentities entity1 = new myentities ();

// Instantiate an object or table

Tableobject Table1 = entity1.tableobject. First (t => T. ID = "primary key of the returned table ");

Return ("/XXX/myview. aspx", Table1 );

}

Then, add a reference to the object on the myview. ASPX page. You can use the MVC tag to bind the object.

If multiple table fields are required, multiple objects (tables) must be returned similarly ).

At this time, you can create a new class under the model file, and then encapsulate all the tables you need in this class. when an object is returned in the background, you only need to return this new class. You can try it on your own.

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.