t0PPy
t0PPy

Reputation: 331

Prevent ContentPlaceHolder from rendering <DIV> tag

Is there any way to prevent a ASP.Net Panel from rendering a DIV?

Upvotes: 1

Views: 1125

Answers (2)

Darkin
Darkin

Reputation: 11

as reflector says:

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

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

Upvotes: 1

Justin Niessner
Justin Niessner

Reputation: 245479

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;

Upvotes: 2

Related Questions