Click here to Skip to main content
15,905,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 2 master pages and one form.based on requirement i want to load master pages differently.can any one help me?
Posted
Comments
m@dhu 4-Feb-11 1:52am    
Why don't you use a usercontrol instead.

You can see this link
Click
Click
 
Share this answer
 
Assume that you are validating the user. Based on logged in user you can change the master pages.
C#
protected void Page_PreInit(object sender, EventArgs e)
{
if(user == "Admin")
{
  this.page.MasterPageFile = "~/Admin.Master";
}
else if(user == "User")
{
  this.page.MasterPageFile = "~/User.Master";
}

}
 
Share this answer
 
v2
Comments
Sandeep Mewara 4-Feb-11 2:40am    
Always use PRE tags to format code part. It makes the answer readable.
Hi,

You can find the solution here
http://odetocode.com/code/450.aspx[^]
what you need to do is load master page according to your business needs on pages's PreInit Event. Another way is to build a simple base class that will do this for you and you can inherit that base page wherever you need to use different master pages.

Hope this will help.
 
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