what's the DIV equivalent to this command?
((Panel)this.Page.Master.FindControl("Panel1")).Style.Add("display", "none");
This works great with a panel but I can't find the variation for doing the same thing with a DIV who's ID I know. anyone know?
thanks in advance for the help!
Div belongs to HtmlGenericControl class of System.Web.UI.HtmlControls namespace.
((HtmlGenericControl)this.Page.Master.FindControl("divID")).Style.Add("display", "none");
and your your div control in master page sholud be runat="server"
Thanks
Asif
If the div is runat="server"
, it is an HttpGenericControl
rather than a Panel
. If the div is not runat="server"
, you cannot access it server-side like you would a WebControl.
If you want to do this from the server-side code (code-behind), then you just have to add the runat="server"
attribute to the DIV:
<div id="myDiv" runat="server">...</div>
Then you access the div the same way as the panel in your example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.