Modifying ViewBag Value in Macro Partial View in Umbraco
Hi Guys,
I have a siutation where I need to store a value in a view bag from a macro partial view, in order to be able to access it in the master page layout.
Considering that Views and Partials get their own ViewBag, as discussed here (http://www.codedisqus.com/0yNeUVXqgq/modifying-mvc-3-viewbag-in-a-partial-view-does-not-persist-to-the-layoutcshtml.html), therefore, can I achieve it Umbraco, to declare a ViewBag in macro partial view and access it in the master page layout from where the parent view in inherting from?
Modifying ViewBag Value in Macro Partial View in Umbraco
Hi Guys,
I have a siutation where I need to store a value in a view bag from a macro partial view, in order to be able to access it in the master page layout.
Considering that Views and Partials get their own ViewBag, as discussed here (http://www.codedisqus.com/0yNeUVXqgq/modifying-mvc-3-viewbag-in-a-partial-view-does-not-persist-to-the-layoutcshtml.html), therefore, can I achieve it Umbraco, to declare a ViewBag in macro partial view and access it in the master page layout from where the parent view in inherting from?
Much appreicated.
Thank you.
Kind Regards
Hi Simon,
Yes you can achieve it from Umbraco. Umbraco runs under the MVC render engine. So you can use what ever the features available in MVC.
See below post.
http://forums.asp.net/t/1705637.aspx?Transfer+values+between+View+and+PartialView+using+ViewBag+
Hope it will help you to get or set Viewbag values from views.
Regards,
Urvish Mandaliya
Hi,
It doesn't work using the @ViewContext.Controller.ViewBag.DayBlockClass = "dayName".
When I set the value of the view bag in the partial view it does not store the value in order to retrieve the value then back to the layout view.
Others suggest to pass the viewbag from the view to the macro partial view but I don't know how to achive this, as described here (http://www.codedisqus.com/0yNeUVXqgq/modifying-mvc-3-viewbag-in-a-partial-view-does-not-persist-to-the-layoutcshtml.html)
Any ideas please?
Thank you.
Kind Regards
is working on a reply...