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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Css Style sheets to use programically

Status
Not open for further replies.

KENDIGIT

Programmer
Mar 26, 2003
17
0
0
US
I currently use a Css called DsStyle.css that is assigned in html as <LINK href="DsStyle.css" type="text/css" rel="Stylesheet">.
I want to define differenct style sheets that are based on the user. If after logging the user in, I want to set the
style sheet to use based on the users definition(ie: color, font, background,foreground using style sheet
user1.css
I'm using Microsoft visual studio and c#, but can't find any way of setting it, programmically.

Thanks.
Ken
 
I'm assuming your using ASP or ASP.net.

Can't you bind a variable to the html code?

in your html <Link href=<%Thatfunkybindingcode&> type="text/css" rel="Stylesheet">

Then change whatever variable is linked to the code to the document text you are looking for.

I'm not an asp guy (if you couldn't tell!)
 
an idea, in your aspx between the head tags
<asp:Literal id="StyleSheet" text="stylesheets" runat="server"></asp:Literal>

in the codebehind
string strColorIndex = cookie.Values["ColorScheme"];
switch (strColorIndex)
{
case "0":
StyleSheet.Text = "<link href=\"greenyellow.css\" type=\"text/css\" rel=\"stylesheet\">";
break;
case "1":
StyleSheet.Text = "<link href=\"bluegray.css\" type=\"text/css\" rel=\"stylesheet\">";
break;
case "2":
StyleSheet.Text = "<link href=\"dbluelblue.css\" type=\"text/css\" rel=\"stylesheet\">";
break;
default:
StyleSheet.Text = "<link href=\"greenyellow.css\" type=\"text/css\" rel=\"stylesheet\">";
break;
}

Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top