<div runat="server" class="labels" style="display:none; height: 100%; font-family: 'Segoe UI';">
<asp:Label ID="Label4" runat="server" Text="Description:" Font-Bold="True"></asp:Label>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label5" runat="server" Text="Impact:" Font-Bold="True"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label6" runat="server" Text="Recommendation:" Font-Bold="True"></asp:Label>
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br /><br />
</div>
I want to change style to display:true as it is know on display: none and i want to done it using c# code. how to call class name and change its style/attributes...
First give an id to your div like this
<div runat="server" id="div1"></div>
And then in your C# code write this to add style to div.
string style = div1.Style[HtmlTextWriterStyle.Display];
if(style.ToLower()=="none")
div1.Style.Add(HtmlTextWriterStyle.Display, "block");
And here is how you can remove style.
div1.Style.Remove(HtmlTextWriterStyle.Display);
<% var display = "block";
if(isHidden){
display = "none";
}
%>
<div runat="server" class="labels" style="display:<%=display%>; height: 100%; font-family: 'Segoe UI';">
<asp:Label ID="Label4" runat="server" Text="Description:" Font-Bold="True"></asp:Label>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label5" runat="server" Text="Impact:" Font-Bold="True"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label6" runat="server" Text="Recommendation:" Font-Bold="True"></asp:Label>
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br /><br />
</div>
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.