473,796 Members | 2,473 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 1156
Wade Beasley <wa**********@i nsightbb.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"] = yourFullPathOfC ssFile;

where yourFullPathOfC ssFile 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
HtmlGenericCont rol.

The code looks something like that in ASPX:

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

Code-Behind:

protected HtmlGenericCont rol MyCssLink;

MyCssLink.Attri butes["href"]=SomeOtherCssFi le....



Nov 18 '05 #3

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

Similar topics

1
1719
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 JavaScript (in DreamweaverMX) to display "buttons" with which to select pages in a gallery. I'm trying to "grey out" (and disable) the button for the current page when it is displayed. (This isn't rocket science here, but it's something that I...
1
1213
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 the DataList ItemStyle CssClass properties are both set to a valid name of a style in a stylesheet located in a subfolder of the App_Themes folder. The Web.config file contains a <pages theme property that references the name of the themes...
8
41524
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{ whatever } </style>
53
4758
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, and .Net2005 code. I'm developing in vb.net 2005. This test sub just reads an input text file, writing out records to another text file, eliminating records that have a '99' in them (it is similar to a CSV file). Some of my concerns are:
10
2688
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 ... ..menuItemStyle{ background:#ddeeff;border-width:1px;border-style:inset;font-family:Arial;font-size:11px
2
3158
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 then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
4
4214
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() + this.ResolveUrl("~") + "styles/styledefault.aspx"); %>" />
2
2468
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.... menuitems.js mmenu.js
15
2188
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 page).... Apparently one can use JavaScript or CSS for this.... Using CSS, it seems that the "trick" is to use * media="print" * in the <linktag.... So if I have a hyperlink to a print-friendly page...um, well, what's
0
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
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 we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.