开发者

State management in MVC 2

开发者 https://www.devze.com 2023-01-14 05:02 出处:网络
I want to show a Session Variable data on View. How can i achieve it. I 开发者_StackOverflow社区am storing some data in Session varaibles and noew i want to display it on View please help me.

I want to show a Session Variable data on View. How can i achieve it. I 开发者_StackOverflow社区am storing some data in Session varaibles and noew i want to display it on View please help me.

I am new Asp.Net MVC 2

Please suggest.


use the ViewData and pass it to the view

in your controller set up something like ViewData["namehere"] = value

then in your View you can call the value of Viewdata["name here"] - think of the ViewData as a bag that you can put properties and their values into and not need to explicitly pass the viewdata to the view for the view to use it


view data is just like session in asp.net so in your controller you can create more than one view data then create you view ,if you want to create a partial control for the view it will alse see the result of the view data but do not forget to cast the result.

0

精彩评论

暂无评论...
验证码 换一张
取 消