How can render dynamic css from custom control based on user settings?I read this article but it is not I want.Style class hasnt got all css properties and direct write style isnt good approach.
-
You can set any CSS property you want as a control property and render it in the control based on what the user wants? Can you be more specific on what you want to style?IrishChieftain– IrishChieftain2012-11-05 23:39:11 +00:00Commented Nov 5, 2012 at 23:39
-
yes,I want to render user settings.user1510685– user15106852012-11-05 23:42:42 +00:00Commented Nov 5, 2012 at 23:42
Add a comment
|
2 Answers
If your styles change on a per user basis, and you want full control over what is rendered, writing the styles yourself is a perfectly good approach.
This is how you can do it:
protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
{
var styleStr = "{color:red}";
writer.AddAttribute(HtmlTextWriterAttribute.Name, "style");
writer.AddAttribute(HtmlTextWriterAttribute.Value, styleStr);
base.AddAttributesToRender(writer);
}