My understanding about your problem is, you want to get the CSS
attributes dynamically using a Server call, rather than just placing the
CSS file in the LINK tag.
If it is right, then look at the below code, the code is for an custom
control which placess <style> tag in the page and reads the CSS file and
writes the CSS tags inside the <style> tag.
...
public class CssWriter : WebControl
{
public CssWriter : base (HtmlTextWriterTag.Style)
{}
void Render(HtmlTextWriter writer)
{
TextReader reader
= new FileStream(this.Server.MapPath("cssfile.css" ...
writer.Write(reader.ReadToEnd());
}
}
...
....
As i mentioned before this code reads the CSS file and places the
content into the Writer object, which inturns writes the CSS tags in the
page. Though I mentioned <style> as a the html tag should be used by the
control thru the constructor atlast, the page will result in writing the
Css tags inside the <style> tag.
If you place this control inside the .aspx file
...
<head>
<cc1:CssWriter id="csw1" runat="server"></cc1:CssWriter>
</head>
...
and look at the View Source from browser, you can see the Css tags are
written inside the <style> tag.
This is pretty straightforward way and efficient as well. But, you
should know little bit about Custom Control development in ASP.NET
for implementing this code properly.
Let me know if this doesn't solves your problem.
--
Vadivel Kumar
http://www.vadivelk.net va**@online.vadivelk.net (remove "online.")
Daves wrote:
what would be the easiest way to create a dynamic css file to link to eg
...
<head>
<link type="text/css" rel="Stylesheet" href="lis.aspx" />
</head>
...
this one quite clumsy since it's creating a whole Page class to simply
create dynamical output (text file)?