473,508 Members | 3,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with ASPX Style Sheet

I have a web site I am working on for a client using ASP.NET with VB.Net
for the language. The client decided they needed the ability to choose
between different page layouts based on a setting in the database. I
have the header and footer working correctly by using a custom base page
and before the Page_Load loading the correct version from a subdirectory
with the Layout Number as the directory name. Now what I need is the
ability to have a similar style sheet in each of the numbered
subdirectories called template.css. Currently all the code for the
screens reside at the root level and the aspx pages point to a root
level "styles.css". What is the best way to accomplish this
redirecting to the correct subdirectory template.css file? Is it in
the base page too? If so how do I replace the currently specified
"styles.css" at runtime?

Thanks,
Wade

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 1148
Wade Beasley <wa**********@insightbb.com> typed:
I have a web site I am working on for a client using ASP.NET with
VB.Net for the language. The client decided they needed the ability
to choose between different page layouts based on a setting in the
database. I have the header and footer working correctly by using a
custom base page and before the Page_Load loading the correct version
from a subdirectory with the Layout Number as the directory name.
Now what I need is the ability to have a similar style sheet in each
of the numbered subdirectories called template.css. Currently all
the code for the screens reside at the root level and the aspx pages
point to a root level "styles.css". What is the best way to
accomplish this redirecting to the correct subdirectory template.css
file? Is it in the base page too? If so how do I replace the
currently specified "styles.css" at runtime?

Try this:

1) Insert inside the HEAD tag the following tag:
<LINK id="lnkStyles" rel="stylesheet" type="text/css" runat="server" />
2) Insert in the method delegate for the PageInit event this code:
this.lnkStyles.Attributes["href"] = yourFullPathOfCssFile;

where yourFullPathOfCssFile is the relative path, with the file name
included, of your css file.

HTH
--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
Nov 18 '05 #2
If I understand you correctly then one method you could use is
HtmlGenericControl.

The code looks something like that in ASPX:

<LINK href="stylesheet1.css" type="text/css" runat="server" id="MyCssLink"
/>

Code-Behind:

protected HtmlGenericControl MyCssLink;

MyCssLink.Attributes["href"]=SomeOtherCssFile....



Nov 18 '05 #3

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

Similar topics

1
1703
by: Anna K. | last post by:
Hi Experts, I'm new to JavaScript and web-based apps development, so I'll tell you right off that I don't really know my way around it as of yet. I'm trying to create a code library set with...
1
1199
by: keithb | last post by:
My ASP.NET 2.0 application has a User Control that contains a DataList that is unable to get style information from a style located in a css file in the themes folder. The user control CssClass and...
8
41492
by: pamelafluente | last post by:
Hi guys, Is it possible to add "onload" (via Javascript) a new class to the <styleheader section? If yes, how would that be done ? <style type="text/css" media="screen"> .NewStyleClass{...
53
4597
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
10
2665
by: pamelafluente | last post by:
Hi, this time I am trying to add a style on the fly.I wish equivalency with this one (only the menuItemStyle line): <head> <style type="text/css" media="screen"> ... some static styles ......
2
3136
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
4
4198
by: coconet | last post by:
Server is Win2K3/IIS6. I have an ASPX page with this in the <headtag: <link rel="stylesheet" type="text/css" href="<% Response.Write( "http://" + Request.ServerVariables.ToString() +...
2
2436
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
15
2117
by: Prisoner at War | last post by:
Okay, I'd like to create a print-friendly website, so I've been reading up on how to create print-friendly pages (without duplicating my site, of course, by having separate versions of each...
0
7228
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
7128
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
7393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.