简体   繁体   中英

Prevent ContentPlaceHolder from rendering <DIV> tag

有什么方法可以防止ASP.Net面板呈现DIV?

You can set the div to be a server-side control and then access it through the code-behind:

<div id="myDiv" runat="server">Some Content</div>

And then wherever you want to set the visibility:

var control = Page.FindControl("myDiv") as HtmlGenericControl;
control.Visible = false;

as reflector says:

public Panel() : base(HtmlTextWriterTag.Div)
{
}

inherit Panel in your class and make constructor with tag you need.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM