0

I can't use ViewData in master page, and I think it's not a smart way to use ContentPlaceHolder control. For example, I want to transfer a string to master page, how should I do? Could you give an example?

WangHongjian
  • 383
  • 6
  • 16
  • 1
    possible duplicate of http://stackoverflow.com/questions/78548/passing-data-to-master-page-in-asp-net-mvc?rq=1 – Ashutosh Mar 28 '14 at 07:19

1 Answers1

0

Use the TempData property to pass data from controller to masterpage. The TempData property value is stored in session state. The value of TempData persists until it is read or until the session times out. If you want pass data one controller view to another controller view then you should use TempData.

public ActionResult NewCustomer()
{
     TempData["SomeValue"] = "";
     return View();
}
Mervin
  • 1