473,770 Members | 7,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using ~/ path for to link a CSS page?

Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>

Is this possible to do with the link element?

Thanks
Jan 17 '08 #1
12 1829
~ is filled in by a routine in WebControl (GetClientPath( ) I think. If not,
it is close). The link is not attached to a control. YOu can code your own
implementation of link that use the routine to covnert ~. Otherwise, you
cannot use ~ to represent route.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
"Lance Wynn" <La********@com munity.nospamwr ote in message
news:OS******** ******@TK2MSFTN GP06.phx.gbl...
Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>

Is this possible to do with the link element?

Thanks

Jan 17 '08 #2
On 17 Січ, 05:08, "Lance Wynn" <Lance_W...@com munity.nospamwr ote:
Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>
If you use href="/style.css" it refers to a stylesheet resided in the
root folder of an application
disregarding of position of the parent page in a website hierarchy.
IMHO, no need to convert the stylesheet link to a server control, a
leading slash "/" for HTML elements do the same as "~/" for web/HTML
controls.

Regards,
Mykola
http://marss.co.ua - Casual ideas for web development
Jan 17 '08 #3
Just to add, if you're refering to Master pages then a Link tag within the
Head section gets resolved before being combined with its content page so
"style.css" should work in your case (also link tags within conditional
comments - thanks Steven). I've just read "ASP.Net 2.0 - Master Pages:
Tips, Tricks, and Traps" by K. Scott Allen
(http://odetocode.com/Articles/450.aspx) which is a great article on the
subject.

Hope that helps.

Best regards

John

"Lance Wynn" <La********@com munity.nospamwr ote in message
news:OS******** ******@TK2MSFTN GP06.phx.gbl...
Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>

Is this possible to do with the link element?

Thanks

Jan 17 '08 #4
"Lance Wynn" <La********@com munity.nospamwr ote in message
news:OS******** ******@TK2MSFTN GP06.phx.gbl...
Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>

Is this possible to do with the link element?
Adding runat="server" should do it:
<link href="~/style.css" rel="stylesheet " type="text/css" runat="server" />
Jan 17 '08 #5
marss brought next idea :
On 17 Січ, 05:08, "Lance Wynn" <Lance_W...@com munity.nospamwr ote:
>Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>

If you use href="/style.css" it refers to a stylesheet resided in the
root folder of an application
disregarding of position of the parent page in a website hierarchy.
IMHO, no need to convert the stylesheet link to a server control, a
leading slash "/" for HTML elements do the same as "~/" for web/HTML
controls.

Regards,
Mykola
http://marss.co.ua - Casual ideas for web development
That will work for a production server where the root of the
application is http://www.company.com.
It will fail on your development box where you want to use
http://localhost/CompanyDevSite

The ~ syntax (when used correctly) will work in both cases.

Hans Kesting
Jan 17 '08 #6
On 17 Січ, 11:44, Hans Kesting <invalid.han... @spamgourmet.co mwrote:
It will fail on your development box where you want to usehttp://localhost/CompanyDevSite
You are right, I completely forgot this aspect.
Perhaps, I became too spoilt by VS 2005 using http://localhost:1720/
instead of http://localhost/MySite/ :)

Regards,
Mykola
http://marss.co.ua - Casual ideas of web development
Jan 17 '08 #7
Another option is to place the stylesheet in the site theme folder. It will
be then automatically referenced from your pages...

--
Patrice

"Lance Wynn" <La********@com munity.nospama écrit dans le message de news:
OS************* *@TK2MSFTNGP06. phx.gbl...
Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>

Is this possible to do with the link element?

Thanks

Jan 17 '08 #8
hi,

here is some code from my MasterPage:
......
<body>
<form id="form1" runat="server">

<div id="main-header" class="box">
<img src="Tema/banner.bmp" alt=""/>
......

i have a "Tema" folder at root directory containing MasterPage and
banner.bmp.
* when i use this code, VS indicates that banner file is missing but at
debug time web browser shows the image, the result is ok.
* when i write there ="~/Tema/banner.bmp", VS says ok but browser says image
missing where it shows the address "localhost/website/~/Tema/banner.bmp"
* when i show the image by vs gui, the code apperas as
src="../Tema/banner.bmp", image is still missing and browser shows the
address "localhost/Tema/banner.bmp"

can anybody who understands the "~" operator, describes this?
"Lance Wynn" <La********@com munity.nospam>, iletisinde þunu yazdý,
news:OS******** ******@TK2MSFTN GP06.phx.gbl...
Hello all,
Is there a way to use the ~/ path to link a CSS page?

I thought maybe something like this would work, but no go:
<link href="~/style.css" rel="stylesheet " type="text/css"/>

Is this possible to do with the link element?

Thanks
Jan 17 '08 #9
"Tahir" <ku*********@gm ail.comwrote in message
news:et******** ******@TK2MSFTN GP04.phx.gbl...
can anybody who understands the "~" operator, describes this?
The tilde (~) is server-side notation, not client-side notation...

That is why something like: <img src="~/Tema/banner.bmp" alt=""/can never
work...

However, <img src="~/Tema/banner.bmp" alt="" runat="server" /will work...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 17 '08 #10

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

Similar topics

6
4840
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms Authentication set up and it worked just fine. Then I realized that I needed to have some pages unsecure. I then created 2 directories. One named Secure and the other named Public. I placed my web.config file in my
3
24035
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked tables in the database where the code resides. If we move the database with the data tables to a new directory, the links are no longer valid. I tried to update the links by changing the Connect property and refreshing: Set td = db.TableDefs(0)...
1
4010
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the live databases on the network. Is there a way, via code, when I get back in-house from being on the road to click a button, and select the backends I want to link to? I would want to delete all the current links and link to the "live"
7
6395
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known location and can display in a browser window. I have my ASP.NET application building links along the lines of file://c:/<path to file>
6
2864
by: Naveen K Kohli | last post by:
I have couple of javascript files that need to be referenced for each content page. So I am trying to put them on Master page. The problem is that content pages are not on one level of the site. I have been trying to find a way to specify path to these JS files so that the actual path to these files correctly gets applied on the path at every level of the folder hierarchies. So far no luck... <script languaage=javascript...
0
1322
by: Amil Hanish | last post by:
Earlier I had inquired as to why a normal <a hreftag didn't work when using the VS hosted site using a random local port. The more I think about it, this seems very wrong. Using the random port hosted site, if I have <a href="/mypage.aspx">, this link doesn't seem to work? I've verified this by creating a simple .htm page with a link like this, then do a "View in browser". Clicking the link results in page not found. I guess this is...
7
2955
by: ApexData | last post by:
Hello I currently Link the FE/BE using the LinkTables Option and the Linked Table Manager. Any time I need to move the BE to another location, I have to go through this process over again. I need the flexibility of being able to move the BE data to wherever I want, without manually going through this process. I just want to change the Path/Filename that I keep in a FE Table. I want to be able to place a Path/Filename in a FE Table...
1
6851
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that i have written for pagination but it displays the link of all the pages at one go i.e. if i have 8 pages showing 10 results per page than it shows links for all 8 pages. Previous 1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80 Next i want to...
1
14058
by: shrik | last post by:
hi everybody. I have following problem. There are two pages. index.jsp and main.jsp in my application Index.jsp contains logging interface in . It submits password and userid to loginform bean. following are entries in struts-config.xml file <action input="index.jsp" name="loginform" path="/login" scope="session" type="com.myapp.struts.loginaction"> <forward name="success" path="/main.jsp"/>
0
9425
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
10230
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...
0
10058
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10004
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,...
1
7416
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
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.