Reputation: 867
how can i set style attribute in code behind c#?
thanks niall
Upvotes: 2
Views: 8918
Reputation: 46425
A user control isn't directly converted to a single HTML object - it is a collection of objects grouped together, therefore you can't set its "style".
If you want to hide it, then it should have a Visible
attribute which you can set to false, however, this means that it won't be rendered to the page at all, and so subsequently can't be made visible in client code.
Upvotes: 4
Reputation: 5903
Basically like this
Control.Style.Add("background-color", "red");
Or like this for any other attribute:
Control.Attributes.Add("style", "color: red;");
Upvotes: 6