Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set layout from controller

Tags:

Is there a way to set the layout from the controller?

have tried:

ViewData["Layout"] = "..." return View("view", Model); 

I know it will sound odd with some people....

like image 322
Valamas Avatar asked Apr 18 '12 07:04

Valamas


People also ask

How do I add a layout in view?

If your view is a ViewGroup (layout) You can use InflaterService. inflate(id, ViewGroup) and set the ViewGroup, it will set the current child(s) with the content of your xml.


1 Answers

View method has overload to set its master layout something like this

return View ("NameOfView",masterName:"viewName"); 
like image 134
Pravin Pawar Avatar answered Dec 08 '22 05:12

Pravin Pawar