How to access the content page control from master page click event ?


masterpage

Hi

One time, i was asked this question in one of my interview “How to access the content page control from master page click event ?”

here is the exact answer, we can access the content page from master page click event using Findcontrol like this

protected void btnClick_Click(object sender, EventArgs e)
{
TextBox txtbox1 = (TextBox)ContentPlaceHolder1.FindControl(“Textbox1”);
if (txtbox1 != null)
{
txtbox1.Text = “Content Textbox”;
}
}

Note: I have written this code in master page on btnclick event

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: