How to get Div of Master Page in page in ASP.net?

20,213

add to the div in the master page the attribute: runat="server" and then in the content page write the following code to access the div:

     Control c=  this.Master.FindControl("masterDiv");// "masterDiv"= the Id of the div.
     c.Visible = false;//to set the div to be hidden.

good luck!

Share:
20,213
Brijesh Patel
Author by

Brijesh Patel

Updated on July 09, 2022

Comments

  • Brijesh Patel
    Brijesh Patel almost 2 years

    I am using Master Page in my Web Application. Now i am creating multiple content pages. there is one Div in the Master page which had label. Now i want to hide that Div in one content page and other requirement in other content page is to get label which is inside the Div.

    So How to hide Div which is in Master Page, from Content Page and how to get label which is defined in that Div from Content page?

  • st mnmn
    st mnmn about 12 years
    if this is the answer you looked for please mark it as the answer