Hi,
At run time, the master page is merged with the content page, but the controls are not directly accessible as master page members because they are protected. The server controls on a master page are local to the master page, which are not accessible by a content page. To make them accessible, the server controls need to be exposed as public properties or methods. Please check the code below.
In your master page make the button visibility to 'false'
<asp:Button ID="btnMaster" runat="server" Text="Show Me" Visible="false" />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
In the masterpage.cs page, create public property to change the button's visibility.
public bool VisibleValue
{
set { btnMaster.Visible = value; }
}
Now in the inbox.aspx page, on the checkbox checked changed event call the masterpage property and set the value to 'true'. This will set the buutton's visibility to 'true' in the master page.
Master property is of type System.Web.UI.Page, and that does not contain properties of your derived class. So you can use the below code.
protected void
CheckBox_selall_CheckedChanged(object sender, EventArgs e)
{
MasterPage mymaster = Master as MasterPage;
mymaster .VisibleValue= true;
}
Now, when you run the code you can see that the button becomes visible when the checkbox is checked.
Happy coding.. :)