Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Changing styles sheets on a per user basis

Reply
Thread Tools

Changing styles sheets on a per user basis

 
 
=?Utf-8?B?VGVycnk=?=
Guest
Posts: n/a
 
      02-04-2004
I'm trying to change styles sheets on a per user basis. I was able to do this on the client using DOM, but how can I do this using the code behind page in the Load Page sub? I have a place that I save the user's preference for style (whihc style sheet they prefer to use), but how do I dynamically load the style sheet from the server at page load time?
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      02-04-2004
Hi Terry,

Inside the <head> tag, add a link tag that is set to run as a server-side
control. Give it an ID but not an href:

<link id="stlysht" rel="styleSheet" runat="server"></link>

In your code behind, declare the control (using the ID) as a generic
control. (Normally, VS.NET does it for you.)

Protected stlysht As _
System.Web.UI.HtmlControls.HtmlGenericControl

In your page load, add an href attribute and the place it should find the
stylesheet:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' Get the cookie preference here
' Use Ifs or Case statements as required
If 1 = 1 Then
stlysht.Attributes.Add _
("href", _
"http://www.aspalliance.com/css/aspalliance.css")
End If
End Sub

Does this help?

Ken
MVP [ASP.NET]


"Terry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to change styles sheets on a per user basis. I was able to do
> this on the client using DOM, but how can I do this using the code behind
> page in the Load Page sub? I have a place that I save the user's
> preference for style (whihc style sheet they prefer to use), but how do I
> dynamically load the style sheet from the server at page load time?


 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGVycnk=?=
Guest
Posts: n/a
 
      02-04-2004
Works like a charm...Many Thanks...Terry
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
splitting an XML file on the basis on basis of XML tags bijeshn@gmail.com Python 14 04-08-2008 04:26 AM
executionTimeout on a per request basis muriwai ASP .Net 2 05-23-2007 06:09 PM
Dynamically using .resx resources on a per-theme basis markarichman@gmail.com ASP .Net 0 03-02-2006 01:04 AM
DHCP on a per-vlan basis? brut Cisco 3 01-09-2006 04:42 AM
CSS applied on a per character basis? Noozer HTML 12 01-19-2005 12:38 AM



Advertisments