473,498 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convenient ~ (tilde) in path does not work in plain HTML?

PJ6
In the VB runtime I can specify paths from the base directory with ~ like
so-

Page.LoadControl("~\Controls\SomeControl.ascx")

but when rendering the LINK tag HTML at runtime, this doesn't work -

<LINK rel="stylesheet" type="text/css" href="~\Styles\Styles.css">

What's the syntax for getting the base directory in HTML, or - much less
desirable - do I have to use a relative path from the page location?

Paul
Nov 19 '05 #1
10 4906
Use the ../Styles/Styles.css synthax. The ../ says to go up one
directory level. You can do ../../ to go up 2 directory levels from
where the page is located.

Nov 19 '05 #2
"PJ6" <no****@nowhere.net> wrote in news:#YOahFqyFHA.2212
@TK2MSFTNGP15.phx.gbl:
What's the syntax for getting the base directory in HTML, or - much less
desirable - do I have to use a relative path from the page location?


Tilde is processed by the server to find the base path.

Unfortunately I don't think there is a method to specify the base
directory, you'll need to use relative paths.

Well one alternative is to use all ASP.NET controls - thus bypassing plain
HTML. There will be more processing overhead, but I'm not sure how much.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #3
hi Paul,
you're using backslashes... these are for local paths only. some browsers
and frameworks might let you away with it though.
it should work if you use forward slashes. a link href is just like any
other web request, so the syntax should work regardless of request type:
html page, gif image, css stylesheet etc.

hyh
tim

--------------------------
blog: http://tim.mackey.ie

"PJ6" <no****@nowhere.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
In the VB runtime I can specify paths from the base directory with ~ like
so-

Page.LoadControl("~\Controls\SomeControl.ascx")

but when rendering the LINK tag HTML at runtime, this doesn't work -

<LINK rel="stylesheet" type="text/css" href="~\Styles\Styles.css">

What's the syntax for getting the base directory in HTML, or - much less
desirable - do I have to use a relative path from the page location?

Paul

Nov 19 '05 #4
Hi,

The problem is that "~" is replaced by ASP.NET engine.
Your HTML is not going through the ASP.NET as it does not even try to interpret what you have wrote if there is no runat="server".

The solution my depends on you problem.

1. If you are working on the website that suppose to work of the ROOT and you are developing in the folder. I can see why you do not want to hardcode the project path. And
My article on codeproject might help you with it
http://www.codeproject.com/aspnet/Multisite.asp

2. You can write the Request.Filter which will convert all "~" to the project path. But then be careful about not having "~" that is suppose to be "~".
George
"PJ6" <no****@nowhere.net> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
In the VB runtime I can specify paths from the base directory with ~ like
so-

Page.LoadControl("~\Controls\SomeControl.ascx")

but when rendering the LINK tag HTML at runtime, this doesn't work -

<LINK rel="stylesheet" type="text/css" href="~\Styles\Styles.css">

What's the syntax for getting the base directory in HTML, or - much less
desirable - do I have to use a relative path from the page location?

Paul
Nov 19 '05 #5
PJ6
Bah then what is the equivalant to IO.Path.Combine? Guess I'll just have to
use string Replace.

BTW, ~ doesn't work at all client-side even using forward-slash.

Paul

"Tim_Mac" <Tim at mackey dot eye eee> wrote in message
news:uJ**************@TK2MSFTNGP15.phx.gbl...
hi Paul,
you're using backslashes... these are for local paths only. some browsers
and frameworks might let you away with it though.
it should work if you use forward slashes. a link href is just like any
other web request, so the syntax should work regardless of request type:
html page, gif image, css stylesheet etc.

hyh
tim

--------------------------
blog: http://tim.mackey.ie

"PJ6" <no****@nowhere.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
In the VB runtime I can specify paths from the base directory with ~ like
so-

Page.LoadControl("~\Controls\SomeControl.ascx")

but when rendering the LINK tag HTML at runtime, this doesn't work -

<LINK rel="stylesheet" type="text/css" href="~\Styles\Styles.css">

What's the syntax for getting the base directory in HTML, or - much less
desirable - do I have to use a relative path from the page location?

Paul


Nov 19 '05 #6
PJ6
OK this works -

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

So how would I get root path and name IIS is using to serve the project
(which may be a different name than what it's called in VS)? I can probably
make the assumption if I have to though.

Thanks for your help,
Paul

"George" <no****@hotmail.com> wrote in message
news:e5**************@TK2MSFTNGP15.phx.gbl...
The problem is that "~" is replaced by ASP.NET engine.
Your HTML is not going through the ASP.NET as it does not even try to
interpret what you have wrote if there is no runat="server".

The solution my depends on you problem.

1. If you are working on the website that suppose to work of the ROOT and
you are developing in the folder. I can see why you do not want to hardcode
the project path. And
My article on codeproject might help you with it
http://www.codeproject.com/aspnet/Multisite.asp

2. You can write the Request.Filter which will convert all "~" to the
project path. But then be careful about not having "~" that is suppose to be
"~".
Nov 19 '05 #7
re:
BTW, ~ doesn't work at all client-side
It's not supposed to.

Client-side is client-side and server-side is server-side,
and never the twain shall meet.

You can send server-side stuff client-side,
but sending client-side stuff server-side will take some contortions.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"PJ6" <no****@nowhere.net> wrote in message news:uk**************@tk2msftngp13.phx.gbl... Bah then what is the equivalant to IO.Path.Combine? Guess I'll just have to use string
Replace.

BTW, ~ doesn't work at all client-side even using forward-slash.

Paul

"Tim_Mac" <Tim at mackey dot eye eee> wrote in message
news:uJ**************@TK2MSFTNGP15.phx.gbl...
hi Paul,
you're using backslashes... these are for local paths only. some browsers and
frameworks might let you away with it though.
it should work if you use forward slashes. a link href is just like any other web
request, so the syntax should work regardless of request type: html page, gif image,
css stylesheet etc.

hyh
tim

--------------------------
blog: http://tim.mackey.ie

"PJ6" <no****@nowhere.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
In the VB runtime I can specify paths from the base directory with ~ like so-

Page.LoadControl("~\Controls\SomeControl.ascx")

but when rendering the LINK tag HTML at runtime, this doesn't work -

<LINK rel="stylesheet" type="text/css" href="~\Styles\Styles.css">

What's the syntax for getting the base directory in HTML, or - much less desirable -
do I have to use a relative path from the page location?

Paul



Nov 19 '05 #8
you can always use Server.MapPath("~") to ger the real path, but then you will need to write a code that would put it into HREF of the <LINK> tag

George
"PJ6" <no****@nowhere.net> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
OK this works -

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

So how would I get root path and name IIS is using to serve the project
(which may be a different name than what it's called in VS)? I can probably
make the assumption if I have to though.

Thanks for your help,
Paul

"George" <no****@hotmail.com> wrote in message
news:e5**************@TK2MSFTNGP15.phx.gbl...
The problem is that "~" is replaced by ASP.NET engine.
Your HTML is not going through the ASP.NET as it does not even try to
interpret what you have wrote if there is no runat="server".

The solution my depends on you problem.

1. If you are working on the website that suppose to work of the ROOT and
you are developing in the folder. I can see why you do not want to hardcode
the project path. And
My article on codeproject might help you with it
http://www.codeproject.com/aspnet/Multisite.asp

2. You can write the Request.Filter which will convert all "~" to the
project path. But then be careful about not having "~" that is suppose to be
"~".
Nov 19 '05 #9
"PJ6" <no****@nowhere.net> wrote in
news:#o**************@TK2MSFTNGP09.phx.gbl:
<LINK rel="stylesheet" type="text/css"
href="/TestWebApp/Styles/Styles.css">

So how would I get root path and name IIS is using to serve the
project (which may be a different name than what it's called in VS)? I
can probably make the assumption if I have to though.

Thanks for your help,
Paul


Can you set the path in code?

Add a RunAt=Server to the Link - then set the StyleSheet path in the
codebehind?

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #10
PJ6
Server.MapPath("~")

Exactly what I was looking for.

Thanks,
Paul

"George" <no****@hotmail.com> wrote in message
news:uh**************@TK2MSFTNGP14.phx.gbl...
you can always use Server.MapPath("~") to ger the real path, but then you
will need to write a code that would put it into HREF of the <LINK> tag

George

Nov 19 '05 #11

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

Similar topics

0
1098
by: CHristian Niss | last post by:
hi there, in a lot of user controls we are using "~" in server tags to reference objects like images <img src="~/images/something.gif" runat="server" />. with framework 1.0 the tilde got...
1
3706
by: MB2 | last post by:
I have code in a User Control for an image button like this: <asp:ImageButton id="__0" runat="server" text="Delete" ImageUrl="~/Images/ImageLibrary/icon_delete.gif" /> This used to work and it...
7
6356
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. ...
10
1585
by: Shawn | last post by:
Hi, For a few years, I have been developing each of my clients websites using a seperate web site (unique IP) to solve problems with relative URL's between my local dev station and the...
9
3300
by: Jared Tullis | last post by:
We have an .NET 1.1 application running on 4 2K3 load balanced servers (using WLBS). IIS has the .NET aspnet_isapi.dll mapped as a wildcard application map. The web.config points *.html to a...
4
14592
by: ibiza | last post by:
Hi all, I have a problem which I don't understand with the "~" mark in a NavigateUrl property of an asp:HyperLink. I have this in a master page, to build the standard menu (rMenuItems is a...
2
1494
by: jbolty | last post by:
There have been a few threads talking about using the tilde ~, to reference the webroot path. My problem though is handling an unexpected tilde in a url. this url: ...
11
2418
by: cdkorzen | last post by:
I'm sorry if this is a rehash, but all I see is the same info. Here's my debacle: I CAN get the PATH_INFO to work. With ANYTHING but ASP. Python, Perl, Cmd files... works fine. ASP can't...
4
4413
by: =?Utf-8?B?QWxm?= | last post by:
Hello all, I am having trouble dealing with ~(tilde) in my .Net 1.1 web application, specially when it comes through the URL. For example, when someone requests the following URL:...
0
7005
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
7168
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,...
1
6891
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...
0
7381
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...
1
4916
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
4595
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...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
293
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.