473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Select CSS stylesheet from C#

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

Jun 13 '06 #1
7 1805
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
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
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

Jun 13 '06 #2
I'm afraid I can't use 2.0. Is this not possible in 1.1?

Bruno Alexandre wrote:
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
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
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


Jun 13 '06 #3
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)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@i40g2000cwc.googlegr oups.com...
I'm afraid I can't use 2.0. Is this not possible in 1.1?

Bruno Alexandre wrote:
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
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
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

Jun 13 '06 #4
Ok yeah I see what you mean. Thanks a lot for your help.

Bruno Alexandre wrote:
Just add a runat attribute to your traditional link tag. ID attribute hasto
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)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@i40g2000cwc.googlegr oups.com...
I'm afraid I can't use 2.0. Is this not possible in 1.1?

Bruno Alexandre wrote:
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
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
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


Jun 13 '06 #5
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")

da*******@gmail.com wrote:
Ok yeah I see what you mean. Thanks a lot for your help.

Bruno Alexandre wrote:
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)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@i40g2000cwc.googlegr oups.com...
I'm afraid I can't use 2.0. Is this not possible in 1.1?

Bruno Alexandre wrote:
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
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
> 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
>


Jun 13 '06 #6
no...

check the link:

http://www.codeproject.com/aspnet/setcssfilelink.asp

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
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")

da*******@gmail.com wrote:
Ok yeah I see what you mean. Thanks a lot for your help.

Bruno Alexandre wrote:
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)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@i40g2000cwc.googlegr oups.com...
I'm afraid I can't use 2.0. Is this not possible in 1.1?

Bruno Alexandre wrote:
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
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
> 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
>

Jun 13 '06 #7
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

da*******@gmail.com wrote:
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")

da*******@gmail.com wrote:
Ok yeah I see what you mean. Thanks a lot for your help.

Bruno Alexandre wrote:
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)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@i40g2000cwc.googlegr oups.com...
I'm afraid I can't use 2.0. Is this not possible in 1.1?

Bruno Alexandre wrote:
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
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
<da*******@gmail.com> escreveu na mensagem
news:11**********************@f6g2000cwb.googlegro ups.com...
> 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
>

Jun 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: RanDeep | last post by:
I have two nodes that both exist underneath the root node. They are linked, however, in the sense that one of the nodes contains a copy of an id that is used to refer to the other. However, when I...
3
by: Colin Toal | last post by:
Hi all, I'm starting to learn XSLT - and have what I think is a very basic question: I have a stylesheet like this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet...
2
by: David Nedrow | last post by:
OK, I have a problem which I'm guessing is simply my inability to figure out a select pattern in XSL. I have an XML file similar to the following: <?xml version="1.0"?> <?xml-stylesheet...
4
by: celerystick | last post by:
This is an xsl question, comp.infosystems.www.authoring.stylesheets were not able to help , here goes .... With one xml file containing repeated element <subject>: ...
1
by: cching | last post by:
Hi, I'm trying to turn this: <Component> <Properties> <Property Name="X" Value="200" /> <Property Name="Y" Value="200" /> <Property Name="Width" Value="100" /> <Property Name="Height"...
3
by: Andy | last post by:
Hi, I'm trying to render tabular data in an HTML document using XSL to transform XML data into an HTML table. Some of the tabular data appears as droplists (implemented by the HTML Select and...
3
by: Patrick | last post by:
Hi All, I'm new to all this and I'm back for more help. I am working with global variables. I'm trying to make my xls just display the data for the defined <moorname>. In my example I am using...
2
by: naima.mans | last post by:
Hello, i want to select 2 following brothers nodes wich are one under another (one closed to another)... i have done one xslt file... but it's not really good.. for example: the xml file:...
4
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.