|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ContentPage : System.Web.UI.Page
{
//raise button click events on content page for the buttons on master page
protected void Page_Init(object sender, EventArgs e)
{
Master.PropertyMasterButton1.Click += new EventHandler(PropertyMasterButton1_Click);
Master.PropertyMasterButton2.Click += new EventHandler(PropertyMasterButton2_Click);
}
//Send text from Master Box 1 to Content Box 1
protected void PropertyMasterButton1_Click(object sender, EventArgs e)
{
//use one of the options below
//option 1. use master page public property
txtContentBox1.Text = Master.PropertyMasterTextBox1.Text;
//option 2. Call master page method
txtContentBox1.Text = Master.GetMasterbox1Value();
//option 3. use FindControl() method of Master object
txtContentBox1.Text = ((TextBox)Master.FindControl("txtMasterBox1")).Text;
}
//Get text from Content Box 2 to Master Box 2
protected void PropertyMasterButton2_Click(object sender, EventArgs e)
{
//use one of the options below
//option 1. User master page's property
Master.PropertyMasterTextBox2.Text = txtContentBox2.Text;
//option 2. call master page's method
Master.SetMasterBox2Value(txtContentBox2.Text);
}
protected void Page_Load(object sender, EventArgs e)
{
}
//send text from Content Box 1 to Master Box 1
protected void btnContentButton1_Click(object sender, EventArgs e)
{
//use one of the options below
//option 1. use master page public property
Master.PropertyMasterTextBox1.Text = txtContentBox1.Text;
//option 2. alternativly, call Master page public method to assign a value to the control on master page
Master.SetMasterBox1Value(txtContentBox1.Text);
}
//Get text from Master Box 2 and display it in Content Box 2
protected void btnContentButton2_Click(object sender, EventArgs e)
{
//use one of the options below
//option 1. access master page's TextBox through a public property exposed on mater page
txtContentBox2.Text = Master.PropertyMasterTextBox2.Text;
//option 2. Call master page public method
txtContentBox2.Text = Master.GetMasterBox2Value();
//option 3. use FindControl() method of Master object
txtContentBox2.Text = ((TextBox)Master.FindControl("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.
Web & Database Developer. Design and implement web and database applications utilizing Microsoft and other development tools.