Data transmission between views and some views (Partial views), viewpartial

Source: Internet
Author: User

Data transmission between views and some views (Partial views), viewpartial

When writing ASP. net mvc programs, we often need to pass data from views to some views (Partial views) or vice versa.

Use Insus. NET today

ControllerBase. TempData

.


The first demonstration is from View to partureview.
Create a controller and add an operation TmTestA ():

 

Create View:

 

To reference the master. Mark #2 to set a value for TempData. Mark #3. Use Html. RenderPartial to Render a partial view.

Create some views. In some views, obtain the data transmitted from the View:

 

OK. Now let's take a look at the running results:

 


Next we try to pass data from some views to the Views.
Open some views, set a value for TempData in the code line #6-#8, that is, some views, and then obtain the data from the view that references this part of views.

Open the view again and refer to code #14-#16 to obtain data.

 

Okay. Run the command to see the effect:

 

Related Article

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.