Technical Training
ASP.NET 2.0Table of Contents
ASP.NET Changing Master Pages Dynamically
ASP.NET Changing Master Pages Dynamically - Page 2ASP.NET Changing Master Pages Dynamically
ASP.NET 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.
Ads
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.
ASP.NET 2.0
- Getting started with ASP.NET 2.0
- .NET Framework Fundamentals
- Microsoft.NET Framework Tools
- Application Development in .NET
- What's New in the .NET Framework 2.0 ?
- Introduction to Visual Studio.NET
- Installing Visual Studio.NET 2005
- Working with Visual Studio.NET Web Applications
- Whats New in ASP.NET 2.0
- Creating an ASP.NET Application
- ASP.NET Code Directory
- ASP.NET Page Object Model
- ASP.NET Server Controls
- ASP.NET Working With Master Pages
- ASP.NET Creating Content for Master Page
- ASP.NET Referencing Master Page Members
- ASP.NET Changing Master Pages Dynamically
- ASP.NET Creating Nested Master Pages
- ASP.NET Working with Web Parts
- ASP.NET Using Web Parts and Controls in Web Pages
- ASP.NET Web Pages and Layout
- ASP.NET - Adding Web Parts at Run Time
- ASP.NET Personalization: User Profiles and Themes
- ASP.NET Data Access features
- ASP.NET State Management
- ASP.NET Customizing the Session State Mechanism
- ASP.NET State Management And Caching
- ASP.NET Security
- Forms Authentication in ASP.NET
- ASP.NET Managing Membership and Roles
- ASP.NET Configuring Page-Level Caching
- ASP.NET Setting Application-Level Caching
- ASP.NET Data Source Object Model
- ASP.NET SqlDataSource Control
- ASP.NET Data Bound Controls
- ASP.NET GridView Control
- ASP.NET GridView Filtering
- ASP.NET Adding Sorting and Paging in GridView
- ASP.NET DataBound Controls - Details View
- ASP.NET Using a Grid to Display Detail Information
- ASP.NET Displaying Master-Detail Data on the Same Page
- Displaying Master-Detail Data on Separate Pages in ASP.NET
- ASP.NET Creating Web Wizards
- ASP.NET : Dynamic Image control
- ASP.NET Advanced Site Functionality







