How to edit the div of the main page from the child page?

what is the div equivalent to this command?

((Panel)this.Page.Master.FindControl("Panel1")).Style.Add("display", "none");

This works fine with the panel, but I cannot find an option to do the same with the DIV that I know. somebody knows?

in advance for your help!

+3
source share
3 answers

The div belongs to the HtmlGenericControl class of the System.Web.UI.HtmlControls namespace.

((HtmlGenericControl)this.Page.Master.FindControl("divID")).Style.Add("display", "none");

and your div control on the main page will be runat="server"

thank

Asif

+10
source

If the div is equal runat="server", it is HttpGenericControl, not Panel. If the div is not runat="server", you cannot get the server side to it, as if you were using WebControl.

+2

(-), runat="server" DIV:

<div id="myDiv" runat="server">...</div>

Then you access the div just like the panel in your example.

+1
source

Source: https://habr.com/ru/post/1769799/


All Articles