Select CSS stylesheet from C#

D

davidfahy

Hi all,
I have written a registration aspx page that I want to "brand"
based on a query string parameter passed to me on a redirect. Basically
if the Service param in the query string is A I want to apply a
stylesheet but if it is B I want to apply a different stylesheet. Is it
possible to select a stylesheet from the Page_Load method in the c#
behind the aspx? Or is there another way to accomplish this?

Thanks in advance
 
B

Bruno Alexandre

you can use skins in ASP.NET 2.0...

Skins are exactly like that, you choose your skin file (it's a CSS file) to
use where in the code you want...

googleit 4 more information under asp.net 2.0 and skins
 
B

Bruno Alexandre

Just add a runat attribute to your traditional link tag. ID attribute has to
be present, and tag has to be properly closed (not like HTML).<head>
<link id="MyStyleSheet" rel="stylesheet" type="text/css" runat="server" />
</head>Then in your Page_Load, simply add a "href" attribute as below:Sub
Page_Load(Sender As Object, E As EventArgs)
If Not (IsPostBack)
MyStyleSheet.Attributes.Add("href","/css/flostyle.css")
End If
End SubHope this helps
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


<[email protected]> escreveu na mensagem
I'm afraid I can't use 2.0. Is this not possible in 1.1?
 
D

davidfahy

I tried this but when i try to build I get and error : The type or
namespace name 'MyStyleSheet' could not be found (are you missing a
using directive or an assembly reference?) at the line
MyStyleSheet.Attributes.Add("href","/mysheet.css")
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

As the object is outside the form, it won't be declared automatically in
the code behind. You have to declare it specifically:

Protected MyStyleSheet as HtmlGenericControl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top