473,322 Members | 1,614 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,322 software developers and data experts.

referencing to style sheet



I am not fully understanding how to refer to another file in the aspx
page.

There is one style sheet which I need to refer to and it is in the root
directory

<LINK href="styles.css" type="text/css" rel="stylesheet">

So how to I refer to that from aspx pages in various sub-directories?
It works if I use relative paths (../styles.css), but not if you are
going to the aspx file from another aspx file from a different
directory.

Tried ~/styles.css hoping that the reference will work no matter where,
but it does not work.

*** Sent via Developersdex http://www.developersdex.com ***
Feb 5 '06 #1
5 1679
David,

You can add further relative pathing;

/folder_with_css_file
|
- sub-folder
|
-sub-sub-folder

With aspx page in "sub-sub-folder", you would extend your realtive path
navigation to add another parent folder directive (../), like this;

<LINK href="../../styles.css" type="text/css" rel="stylesheet">
^^

Hope that helps

Al
"David C" <no*******@nospam.com> wrote in message
news:eB****************@TK2MSFTNGP11.phx.gbl...


I am not fully understanding how to refer to another file in the aspx
page.

There is one style sheet which I need to refer to and it is in the root
directory

<LINK href="styles.css" type="text/css" rel="stylesheet">

So how to I refer to that from aspx pages in various sub-directories?
It works if I use relative paths (../styles.css), but not if you are
going to the aspx file from another aspx file from a different
directory.

Tried ~/styles.css hoping that the reference will work no matter where,
but it does not work.

*** Sent via Developersdex http://www.developersdex.com ***

Feb 5 '06 #2
In order for ASP.NET to resolve the ~/styles.css the element must be a
server control:

<link href="styles.css" type="text/css" rel="stylesheet" runat="server"
/>

I don't think this works in ASP.NET 1.x though, but this does:

<link href="<%=Page.ResolveUrl("~/styles.css")%>" type="text/css"
rel="stylesheet" />

Josh
http://www.thejoyofcode.com/

Feb 5 '06 #3
I DO NOT want to have to use relative paths, so this one will not work.

"Alec MacLean" <al**********@NO19SPAM60.copeohs.com> wrote in message
news:uA*************@TK2MSFTNGP12.phx.gbl...
David,

You can add further relative pathing;

/folder_with_css_file
|
- sub-folder
|
-sub-sub-folder

With aspx page in "sub-sub-folder", you would extend your realtive path
navigation to add another parent folder directive (../), like this;

<LINK href="../../styles.css" type="text/css" rel="stylesheet">
^^

Hope that helps

Al
"David C" <no*******@nospam.com> wrote in message
news:eB****************@TK2MSFTNGP11.phx.gbl...


I am not fully understanding how to refer to another file in the aspx
page.

There is one style sheet which I need to refer to and it is in the root
directory

<LINK href="styles.css" type="text/css" rel="stylesheet">

So how to I refer to that from aspx pages in various sub-directories?
It works if I use relative paths (../styles.css), but not if you are
going to the aspx file from another aspx file from a different
directory.

Tried ~/styles.css hoping that the reference will work no matter where,
but it does not work.

*** Sent via Developersdex http://www.developersdex.com ***


Feb 5 '06 #4
It works....Thanks...BUT, got a big problem. Once I do that to a page, it
does not let me add a literal control to the page any more, and it shows the
following error message.

The Controls collection cannot be modified because the control contains code
blocks (i.e. <% ... %>).

"Josh Twist" <jo********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
In order for ASP.NET to resolve the ~/styles.css the element must be a
server control:

<link href="styles.css" type="text/css" rel="stylesheet" runat="server"
/>

I don't think this works in ASP.NET 1.x though, but this does:

<link href="<%=Page.ResolveUrl("~/styles.css")%>" type="text/css"
rel="stylesheet" />

Josh
http://www.thejoyofcode.com/

Feb 5 '06 #5
Hmm... you could put that code into a user control and place the user
control on each page instead of the <link> element itself.

Josh
http://www.thejoyofcode.com/

Feb 6 '06 #6

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

Similar topics

2
by: Mark | last post by:
Hi - I want to allow users of an intranet application, to select their own colours etc. So I have a tbale in my database, which has fields called bgcolour, fontcolour etc. As I want all pages...
2
by: Luke Bellamy | last post by:
Hi, I have been looking for a way to incorperate several different style sheets into a web page (i.e cascading effect). I have looked into the @import statement which seems to do what I want but...
5
by: Andrew Poulos | last post by:
If I have an external stylesheet that is @imported into my page and it has an element that looks like this: * html td { font-style: italic; } how can I use javascript to change the font...
7
by: Daniel Kaplan | last post by:
I have the item below at the top of my style sheet. And it seems that the font-szie is ignored. I know that my linked style sheet is being read, and used because if I remove the font-family line,...
1
by: Amanda H. | last post by:
I posted about this a few days ago, and I got a few suggestions that fixed part of my problem. I am using a PHP script to switch external style sheets when the viewer clicks on the style link. ...
8
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{...
10
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 ......
4
by: fjm | last post by:
Hello everyone. I’d like to know how to handle multiple style sheets. I have css tabs that have a style sheet and then I also have a separate style sheet for the content that goes inside the tab. ...
4
Frinavale
by: Frinavale | last post by:
So a while ago I created a Tab Strip Control (before the AjaxToolkit had theirs otherwise I would have probably just used theirs). When I looked at the AjaxToolkit control to see how they got...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.