.net - Adding CSS class through ASPX code -
i using aspx. if have html follows:
<div id="classme"></div>
i hoping dynamically add css class through code behind file, i.e. on page_load
. possible?
if want use control on serverside make runat=server
or better: use servercontrol in first place. in case should use panel
rendered div
:
<asp:panel id="panelid" cssclass="classme" runat="server"></asp:panel>
or codebehind:
protected void page_load(object sender, eventargs e) { panelid.cssclass = "classme"; }
but if want stay div
:
<div id="divid" runat="server"></div>
codebehind:
protected void page_load(object sender, eventargs e) { divid.attributes.add("class", "classme"); }
Comments
Post a Comment