Click here to Skip to main content
15,898,222 members
Articles / Web Development / HTML

Interaction Between Content Page and Master Page

Rate me:
Please Sign up or sign in to vote.
4.94/5 (15 votes)
30 Apr 2009CPOL5 min read 159.1K   3.5K   58  
Discussion on the concept and implementation of interaction between a content page and a master page.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        txtMasterBox1.Focus();
    }


   
    //expose controls on master page as public properties
    public TextBox PropertyMasterTextBox1
    {
        get { return txtMasterBox1; }
        set { txtMasterBox1 = value; }
    }
    public TextBox PropertyMasterTextBox2
    {
        get { return txtMasterBox2; }
        set { txtMasterBox2 = value; }
    }
    public Button PropertyMasterButton1
    {
        get { return btnMasterButton1; }
    }
    public Button PropertyMasterButton2
    {
        get { return btnMasterButton2; }
    }

    //expose public methods on master page for content page to call
    public void SetMasterBox1Value(string myText)
    {
        txtMasterBox1.Text = myText;
    }
    public string GetMasterbox1Value()
    {
        return txtMasterBox1.Text;
    }
    public void SetMasterBox2Value(string myText)
    {
        txtMasterBox2.Text = myText;
    }
    public string GetMasterBox2Value()
    {
        return txtMasterBox2.Text;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Web & Database Developer. Design and implement web and database applications utilizing Microsoft and other development tools.

Comments and Discussions