I want send to output CSS info in style blocks
protected override void RenderContents(HtmlTextWriter output)
{
...
output.Write("<style> .... ");
}
But this block cant be nested in div block .I must place it in head.How can I do it or is there another approach?
Derive from
System.Web.UI.Control
directly and override theRender
method, instead of deriving from (what I assume is)System.Web.IO.WebControls.WebControl
.The
this.Page.Header.Stylesheet.CreateStyleRule
method lets you add styles to the<head>
. However, the CSS attributes that you can specify are limited to those supported by theStyle
class. (You can derive your own class fromStyle
if you need additional attributes.)C# example: