Priyanka
Priyanka

Reputation: 2832

How to retrieve style of the HTML server control programmatically?

Suppose i'm having <div> tag with id="toggleText" & runat="Server" then i can change style attributes by using following -

toggleText.Style.Add("Display", "block");

But if i want to retrieve the style attribute then how to do this?

thanks

Upvotes: 1

Views: 583

Answers (2)

Andy Stannard
Andy Stannard

Reputation: 1703

Easy:

 toggleText.Style["Display"];

Upvotes: 3

stuartd
stuartd

Reputation: 73253

When you query the control's Style property you get "a collection of all cascading style sheet (CSS) properties applied to a specified HTML server control in the ASP.NET file" - there's a code sample on that page as well.

Upvotes: 1

Related Questions