Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic use of CSS files

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
CA
Hi All,

I am interested in using a CSS file in my aspx page, the catch being that I want to dynamically set the directory location of the css file to use. I have tried declaring a protected variable in my aspx.cs page and then setting the value in the Page_Init method. To no avail. The variable does not seem to get set.

If anyone has done anything similar it would be very helpful if you could give me some leads.

Thanks in advance Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Hmmm...have you tried setting the css in the html code link tag?

so in the html it would look like

<LINK css=<% somevariableholdingthenewlocation %>>

sorry, I know that isn't the 100% correct syntax, but you get the idea. Might be easier than trying it in the code behind.

Jack
 
I actually tried that but being new to asp.net I may have messed up my syntax. In the end what I did is

In Code Behind Page

Code:
string strTemp;

strTemp=&quot;<LINK rel=\&quot;stylesheet\&quot; type=\&quot;text/css\&quot; href=\&quot;&quot; + strCSS + &quot;\&quot;>&quot;;

Page.RegisterStartupScript(&quot;Startup&quot;,strTemp);

This seems to work just fine. Now my issue is that I want no hardcoded content in the page. I thought to use resource files to provide the values for the name value pairs capabilities and dynamically select which one I want in the same way that I do with the css file.
But I do not really understand the whole resource file thing very well (again I am new to .net development).

I also considered using some kind of include files, but I do remember that back when I was doing asp you could not dynamically set which file to include.

So if anyone has any good ideas for this I would love to hear them. Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top