MoonLight MoonLight - 1 year ago 110
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

Answer Source

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>