alt
Advertisement
Sponsored links
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow ASP.NET 2.0 arrow ASP.NET 2.0 :Changing Master Pages Dynamically
Site Search


ASP.NET 2.0 :Changing Master Pages Dynamically
Article Index
ASP.NET 2.0 :Changing Master Pages Dynamically
Page 2

ASP.NET 2.0 Free Training : Changing Master Pages Dynamically

In this tutorial you will learn how to make a copy of the master page, To add buttons for selecting an alternate master page, To write code to dynamically select the master page and test the dynamic master pages.

Changing Master Pages Dynamically

Dynamically changing master pages is possible. The code can be used to set the master for the content. This may especially be useful when users want to select from several different layouts to set their preferences. To see how this is done let us add another Master page to our website and allow the user to select the template he wants.

The first step is to make a copy of the Master as we want the second page to approximate to the first Master.

To make a copy of the master page

1. In Solution Explorer, right-click MasterPag.master, and then click Copy.

2. Right-click the name of the Web site, and then click Paste.

3. A master page is added to the Web site with the name Copy of masterPage.master.

4. Right-click Copy of masterPage.master, click Rename, and then name the new master page MasterPage2.master.

5. Open Master2.master and in the @ Master directive, change MasterPage to MasterPage2.

6. Switch to Design view.

7. In the Properties window, in the drop-down list at the top, click DOCUMENT.

8. Set the BgColor property to the color of your choice.

9. The new master page will look and function like MasterPage.master, but will have a different background color

10. Open the master page's code file, and then change the class name from MasterPage_master to MasterPage2_master.

The next step is to add a button to each master page that allows the user to select the alternate master page.



 
< Prev   Next >
Exforsys Offers
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape