Technical Training
ASP.NET 2.0Table of Contents
ASP.NET Referencing Master Page Members
ASP.NET Referencing Master Page Members - Page 2ASP.NET Referencing Master Page Members
ASP.NET Referencing Master Page Members
In this tutorial you will learn about reference Master Page Mebers, add property to Master Page, expose Master Properties.
Ads
Referencing Master Page Members
Members of the Master page can be referenced by content pages. These members can be methods, properties or controls. The constraint for property reference is theat the property has to be declared as public members of the master page. They could be public page scope variables, public propertis and public methods. Let us work out a simple example. The developer wants to set the title of a content page or to add a style sheet on a per page basis. Code will have to be added to the Page_Load event. The Header property on the Page class exposes the content of the< head > tag as programmable entities.
To add a property to the master page
1. Open the MasterPage.master page.
2. In Solution Explorer, right-click MasterPage.master, and then click View Code to open the code editor.
3. Type the following code in the Home.aspx:
...................< Script runat=”server” >
.................................Void Page_Load(object sender, EventArgs e)
................................{
.............................................Header.title= “This is another title”;
................................}
...................< /Script >

4. The code sets a different title for the master.

To expose Master Properties
A control can be given an identity in the master by simply setting the runat attribute and giving the control an ID. The control can then be accessed from within the content page through the Master property. The Master property defined on the Page class references the master page object for the content page. It implies that only public properties and method defined on the master page class are accessible.
Let us say that the requirement is that a subtitle has to be exposed as a programmable property. First we shall render the string through a server side control and then we shall create a public wrapper property to make the control accessible from the content page. Add the following code to the masterpage.master. The code defines the public SubTitle and wraps the InnerText property of the _titlebar control.
1. Open MasterPage.master
2. Enter the following code below @Master directive.
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







