Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I have a web application with 2 master pages in it. My client wants to change look of the web application each month. For that purpose I created 2 more master pages with different look and feel. The problem I am facing is changing master pages dynamically. One option I have is to change it in Page_PreInit () of each page of the application but the application has around 200 web pages. Is there any other more elegant way to achieve this ?
Posted
Comments
Sergey Alexandrovich Kryukov 8-Jun-11 22:49pm    
May I ask you: what do those master pages (holding identical content) have in common in terms of look at feel? Does the user recognize it is the same company; or the company does not have permanent users?
--SA
virang_21 8-Jun-11 23:00pm    
Client is an education provider ( Business College ) . Those master pages contain menu which is identical but background image on the master page is different (One big image cut into 3 different parts) . The big issue I am facing is that the background images for both the master pages are not cut exactly same pixels ( Image 1 : Part A : 225 X 650 , Image 2 : Part A : 179 X 650 ). The problem is that graphics designer works just one day for client and always busy with other work and client expect things get done ASAP. That is the reason I created 2 master pages with different background to give it different look ( Workaround when resources are not available :-( ).

1 solution

Yes, there is a way to do that. But I wonder why you need two master pages. Isn't one enough for you ? If you create to change the look and feel, It is better to play with CSS, Not master page.Anyways, Here is the solution.

Instead of putting code in each page PreInit() event, Put the same code to the master page PreInit() event.Here is MSDN article how to do this.Working with ASP.NET Master Pages Programmatically[^]

I hope this helps you well.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Jun-11 22:51pm    
Good answer, my 5. However, the whole idea of changing the look and feel looks a suspect to me.
--SA
Wonde Tadesse 8-Jun-11 22:53pm    
Thanks --SA.

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