In ASP.Net using
asp:Panel
renders a
div
. So define a css class in a style file or in the page and from code-behind set the
CssClass
property (or set in the .aspx page itself.
For example, in the aspx:
<asp:panel id="panel" runat="server" xmlns:asp="#unknown">
</asp:panel>
Then in the code-behind:
protected void Page_Load(object sender, EventArgs e)
{
panel.CssClass = "some-class";
}
or
<asp:panel id="panel" runat="server" cssclass="some-class" xmlns:asp="#unknown">
</asp:panel>
(or)
<div id="div1" runat="server">
</div>
protected void Page_Load(object sender, EventArgs e)
{
div1.Attributes.Add("class","some-class");
}
As a side note, you could also use the "style" client-side property.
Hope this helps!