Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have scenario ,for a multiple clients different layout i have render,so how can i render different layout for common views...i don't want create multiple layout pages,it should change dynamically based on dB information
Posted

you need to render different view

or can use page by providing page id and shou after check db
 
Share this answer
 
As per your requirement you want to show different layout, but dont want to create different layout page.
It is possible if you have any property of your current user object which shows the client then on your layout page simple you can use code to check the current client and write your different layout structure for that client.

@if (User.CurentClient=="ClientOne")
                        { 
<div id="header>
<ul>
<li>Home</li>
<li>About</li>
</ul>
</div>
<div id="Main">
 @RenderBody()
</div>

}
else if(User.CurentClient=="ClientTwo")
{
<div id="header>
 <span>Title one>
</div>
<div id="otherDiv"><span>any other div Conent</div>
<div id="Main">
 @RenderBody()
</div>

}
else
{
//this will your default arrangement of div and other element on layout.
<div>
@RenderBody()
</div>
}



In this code you simply checking the current user client and Creating Layout for that client and rendering views in that layout.
other things like js,css can also be be separated as the above.

use this code in _Layout.Cshtml
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900