Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a master page where contententplaceholder1 is defined and on the master page have two buttons, buttonA and buttonB. I have a aspx page "page.aspx" which has a content2 which load in contentplaceholder1 of master page.

on page.aspx there are two asp panel PanelA and PanelB. How can i enable PanelA of page.aspx when buttonA in the master page is clicked and disable PanelB and Vice-Versa.

Please help.

Regards
KD
Posted

You need to find control inside content page from master page, for that you can use find control method several times based on control hierarchy. Refer http://weblog.west-wind.com/posts/2006/Apr/09/ASPNET-20-MasterPages-and-FindControl[^] and it will help you to find control.
 
Share this answer
 
I Have Created a function in master.cs and than passed the control by id to the function. Please find complete code below.

protected void btnUpload_Click(object sender, ImageClickEventArgs e)
{
try
{
var control = FindWebControlByIdInControl(this, "pnUploadFile");
if (control != null)
{
control.Visible = true;
}
}
catch (Exception ex)
{
}
}



private WebControl FindWebControlByIdInControl(Control control, string id)
{
foreach (Control childControl in control.Controls)
{
if (childControl.ID != null && childControl.ID.Equals(id, StringComparison.OrdinalIgnoreCase) && childControl is WebControl)
{
return (WebControl)childControl;
}

if (childControl.HasControls())
{
WebControl result = FindWebControlByIdInControl(childControl, id);
if (result != null) return result;
}
}

return null;
}
 
Share this answer
 
Comments
You should update the question with codes. Don't add it as an answer. Also follow find control technique given by DamithSL.
Kedar.Kamwal 4-Jan-15 21:47pm    
ok

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900