Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can we Pass Data From Partial Views To Parent View Controller Action methods
Posted

1 solution

In .NET MVC you have a couple of options to pass values around. when going controller-to-controller, you can use the TempData[] collection for single hops. Only controllers can access this collection, and it is primarily useful for action redirects.

If you need to persist data for a use in a given session, you can use the Session[] collection to provide an application state per user, per session. All views and controllers can access this collection.

You can use the ViewData[] collection to pass elements into the view and assign them to variable containers (such as JavaScript variables) that are known by the Master view. You can then make any changes on the client side using JavaScript.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900