Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

ASP.NET Referencing Master Page Members

By Exforsys | on August 17, 2005 |
ASP.NET 2.0

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.

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.

Click here to view sample code

.

.

The < span > element marked runat=server is mapped to an HTMLGenericControl object and its text content is exposed through the InnerText property. This property is wrapped by a new public property “SubTitle” that gets and sets the value of the InnerText property on the < span > tag.

Now this property can be invoked from the master if the SubTitle propertyis defined on the MasterPage class. This is because the MasterPage class represents the masterpage object which is compiled at runtime. The ClassName attribute on the @Master directive allows the assignment of user defined names to the master page class. Therefore the master property must be cast to the actual type to be able to call custom properties. The following code will have to be added to the content page

((MasterPage)Master).SubTitle= “Welcome”;

Now add the following code to the content page.

< script runat= “Server” >
………Void Page_Load(object sender, EventArgs e)
………{
………………Master. SubTitle = “Welcome”;
………}
< /Script >

 

 

« « ASP.NET Creating Content for Master Page
ASP.NET Working With Master Pages » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 392 Followers
  • Popular
  • Recent
  • Application Development in .NET

    November 21, 2007 - 0 Comment
  • ASP.NET Security

    September 2, 2005 - 0 Comment
  • Creating an ASP.NET Application

    August 11, 2005 - 0 Comment
  • ASP.NET DataBound Controls – Details View

    September 13, 2005 - 0 Comment
  • What’s New in the .NET Framework 2.0 ?

    July 26, 2005 - 0 Comment
  • Forms Authentication in ASP.NET

    September 2, 2005 - 0 Comment
  • ASP.NET Code Directory

    August 12, 2005 - 0 Comment
  • ASP.NET Using a Grid to Display Detail Information

    September 13, 2005 - 0 Comment
  • ASP.NET Working with Web Parts

    August 22, 2005 - 0 Comment
  • ASP.NET Managing Membership and Roles

    August 6, 2005 - 0 Comment
  • Application Development in .NET

    November 21, 2007 - 0 Comment
  • ASP.NET Advanced Site Functionality

    September 16, 2005 - 0 Comment
  • ASP.NET : Dynamic Image control

    September 16, 2005 - 0 Comment
  • ASP.NET Creating Web Wizards

    September 16, 2005 - 0 Comment
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

    September 16, 2005 - 0 Comment
  • ASP.NET Displaying Master-Detail Data on the Same Page

    September 13, 2005 - 0 Comment
  • ASP.NET DataBound Controls – Details View

    September 13, 2005 - 0 Comment
  • ASP.NET Using a Grid to Display Detail Information

    September 13, 2005 - 0 Comment
  • ASP.NET Adding Sorting and Paging in GridView

    September 10, 2005 - 0 Comment
  • ASP.NET GridView Filtering

    September 10, 2005 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • Application Development in .NET
  • ASP.NET Advanced Site Functionality
  • ASP.NET : Dynamic Image control
  • ASP.NET Creating Web Wizards
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT