0

To send a value from partial view to layout view . i used in partial view as

viewbag.var="Device"  

and retrieve value on layout view by

<h1> @viewbag.var </h1>

but not showing any values.plaese help .thanks in advance

sarath
  • 314
  • 6
  • 15
  • Try to use (ViewBag) instead of (viewbag) – Ala Aug 10 '15 at 10:05
  • i tried it but not working – sarath Aug 10 '15 at 10:08
  • The partial uses a separate `ViewDataDictionary`. The [answers here](http://stackoverflow.com/questions/4974027/modifying-mvc-3-viewbag-in-a-partial-view-does-not-persist-to-the-layout-cshtml) give a few options you could consider –  Aug 10 '15 at 11:06
  • @Stephen I need to print the separete heading for each partial view.. how can I implement that? – sarath Aug 10 '15 at 11:29
  • Then why don't you include the heading in the partial? But the link I gave in my last comment has some solutions. –  Aug 10 '15 at 11:31
  • I want to print the headings on dashboard section ,which is in the layout view. @stephen – sarath Aug 10 '15 at 11:39

1 Answers1

0

Try to use TempData: TempData["var"]="Device"

Krylatka
  • 21
  • 2