ASP.Net MVC is a popular platform to design dynamic website
and CRM etc. One I was stuck in a situation when I want to use a common view
to different privileged users. So I had to bind multiple layouts on a single view
as per the related users menu or sidebar. This post will help you to bind
dynamic layouts on a single view.
public ActionResult
Task()
{
CommonRepository
ob = new CommonRepository();
AdminDashboardModel
data = new AdminDashboardModel();
data =
ob.GetOtherUsersDashbaord(Request.Cookies["UID"].Value);
string
Layout = "";
switch
(Request.Cookies["Type"].Value)
{
case "Designer":
Layout = "~/Views/Shared/_LayoutDesigner.cshtml";
break;
case "IT":
Layout = "~/Views/Shared/_LayoutIT.cshtml";
break;
case "Sales":
Layout = "~/Views/Shared/_LayoutSales.cshtml";
break;
case "Coordinator":
Layout = "~/Views/Shared/_LayoutOperator.cshtml";
break;
case "Admin":
Layout = "~/Views/Shared/_LayoutOperator.cshtml";
break;
}
return
View("Task", Layout,data);
}
No comments:
Post a Comment