MoonLight MoonLight - 2 months ago 8x
ASP.NET (C#) Question

How read(get) css style value of a server-side div in code behind(not set)?

i want to get 'display' css value of a server side div!

the code below does not work :

if (div.Style["display"] == "none")
div.Style.Add("display", "table-row");

how can i get that value in c#?

thanks in advance


You can't do what you are trying to do on the server side. The Style property only works with the inline styling. Consider client side JavaScript.

<div id="div" runat="server" style="display: none;">Foo</div>