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: