473,324 Members | 2,124 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,324 software developers and data experts.

Implementing ~/...

I am creating some custom links via code on my Web site.

One problem I have is that I might write a link as /Images/img.gif. On my
Web site, that should work find. But on my local test computer, it is wrong
because / actual refers to the root of my developer server folder.

What I really want is ~/Images/img.gif but I'm not using a label control. Is
there a function that will take ~/Images... and change it to be the path off
my project's root dir? Perhaps the same routine called by the label
controls, etc?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jan 31 '07 #1
6 977
AFAIK this is Control.ResolveUrl. Try
http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...

"Jonathan Wood" <jw***@softcircuits.coma écrit dans le message de news:
uR**************@TK2MSFTNGP06.phx.gbl...
>I am creating some custom links via code on my Web site.

One problem I have is that I might write a link as /Images/img.gif. On my
Web site, that should work find. But on my local test computer, it is
wrong because / actual refers to the root of my developer server folder.

What I really want is ~/Images/img.gif but I'm not using a label control.
Is there a function that will take ~/Images... and change it to be the
path off my project's root dir? Perhaps the same routine called by the
label controls, etc?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Jan 31 '07 #2
Jonathan,

I am not sure why can't you use ~/Images/img.gif as it is. Asp.Net will
compile this reference to Request.ApplicationPath. Obviously, it will work
only for server-side controls, but you can turn any control to a server-side
one by just adding runat=server.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:uR**************@TK2MSFTNGP06.phx.gbl...
>I am creating some custom links via code on my Web site.

One problem I have is that I might write a link as /Images/img.gif. On my
Web site, that should work find. But on my local test computer, it is
wrong because / actual refers to the root of my developer server folder.

What I really want is ~/Images/img.gif but I'm not using a label control.
Is there a function that will take ~/Images... and change it to be the
path off my project's root dir? Perhaps the same routine called by the
label controls, etc?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Jan 31 '07 #3
Control.ResolveUrl produces an url usable on client side. If I understand
Jonathan correctly, he needs to get right the server-side reference, that it
what Control.ResolveUrl takes to produce a client-side reference.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Patrice" <http://www.chez.com/scribe/wrote in message
news:eI****************@TK2MSFTNGP04.phx.gbl...
AFAIK this is Control.ResolveUrl. Try
http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...

"Jonathan Wood" <jw***@softcircuits.coma écrit dans le message de news:
uR**************@TK2MSFTNGP06.phx.gbl...
>>I am creating some custom links via code on my Web site.

One problem I have is that I might write a link as /Images/img.gif. On my
Web site, that should work find. But on my local test computer, it is
wrong because / actual refers to the root of my developer server folder.

What I really want is ~/Images/img.gif but I'm not using a label control.
Is there a function that will take ~/Images... and change it to be the
path off my project's root dir? Perhaps the same routine called by the
label controls, etc?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Jan 31 '07 #4
Then it would be Server.MapPath. As Jonathan talked about a "link" I thought
the problem was that the hyperlink is not correct client side...

Jonathan, as suggested by Eliyahu you could perhaps still have this done
automatically. We know that you don't use a label but you may want to tell
use which control exactly you are using...

----
Patrice

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orga écrit dans le
message de news: eu**************@TK2MSFTNGP02.phx.gbl...
Control.ResolveUrl produces an url usable on client side. If I understand
Jonathan correctly, he needs to get right the server-side reference, that
it what Control.ResolveUrl takes to produce a client-side reference.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Patrice" <http://www.chez.com/scribe/wrote in message
news:eI****************@TK2MSFTNGP04.phx.gbl...
>AFAIK this is Control.ResolveUrl. Try
http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...

"Jonathan Wood" <jw***@softcircuits.coma écrit dans le message de news:
uR**************@TK2MSFTNGP06.phx.gbl...
>>>I am creating some custom links via code on my Web site.

One problem I have is that I might write a link as /Images/img.gif. On
my Web site, that should work find. But on my local test computer, it is
wrong because / actual refers to the root of my developer server folder.

What I really want is ~/Images/img.gif but I'm not using a label
control. Is there a function that will take ~/Images... and change it to
be the path off my project's root dir? Perhaps the same routine called
by the label controls, etc?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com




Jan 31 '07 #5
I'm emitting HTML in a control's Render event via writer.Write().

If I emit a path with ~/, that will pass unchanged to the web page.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:ut**************@TK2MSFTNGP06.phx.gbl...
Jonathan,

I am not sure why can't you use ~/Images/img.gif as it is. Asp.Net will
compile this reference to Request.ApplicationPath. Obviously, it will work
only for server-side controls, but you can turn any control to a
server-side one by just adding runat=server.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:uR**************@TK2MSFTNGP06.phx.gbl...
>>I am creating some custom links via code on my Web site.

One problem I have is that I might write a link as /Images/img.gif. On my
Web site, that should work find. But on my local test computer, it is
wrong because / actual refers to the root of my developer server folder.

What I really want is ~/Images/img.gif but I'm not using a label control.
Is there a function that will take ~/Images... and change it to be the
path off my project's root dir? Perhaps the same routine called by the
label controls, etc?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Jan 31 '07 #6
Yep, that did it. Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Patrice" <http://www.chez.com/scribe/wrote in message
news:eI****************@TK2MSFTNGP04.phx.gbl...
AFAIK this is Control.ResolveUrl. Try
http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...

"Jonathan Wood" <jw***@softcircuits.coma écrit dans le message de news:
uR**************@TK2MSFTNGP06.phx.gbl...
>>I am creating some custom links via code on my Web site.

One problem I have is that I might write a link as /Images/img.gif. On my
Web site, that should work find. But on my local test computer, it is
wrong because / actual refers to the root of my developer server folder.

What I really want is ~/Images/img.gif but I'm not using a label control.
Is there a function that will take ~/Images... and change it to be the
path off my project's root dir? Perhaps the same routine called by the
label controls, etc?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Jan 31 '07 #7

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

Similar topics

1
by: MKoleoso | last post by:
Problem: C#- Unable to create instance of a class implementing from an interface I have: namespace someNamespace { public __gc class SomeClass1 { }
1
by: Maurice | last post by:
Hi, We are implementing some wrappers in C++ according to the Adapter Pattern. The classes and their methods in the Adaptee classes (open-source library) have already the interface that we like,...
4
by: Frank J. Reashore | last post by:
Hello Everyone, I am implementing a simple interface in C# using Visual Studio .net and was quite surprised to discover that the C# compiler does NOT complain if a method on the interface is not...
7
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I...
4
by: phl | last post by:
hi, My question is: 1. To avoid possible memory leaks, when you use this pattern, after you have dealth with the unmanaged resources and before you take your object off the finalize queue,...
6
by: Raj Wall | last post by:
Hi, I am trying to implement the IEqualityComparer interface for a struct so I can use it as the Key for a Dictionary. My struct declaration has: public struct Ring : IEqualityComparer {...
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
2
by: Ian Semmel | last post by:
I am new to this world of ASP.NET so forgive the dumb questions. I have been looking at the sample provided 'Implementing a Session-State Store Provider' in an effort to understand how the...
4
by: Mohamed Mansour | last post by:
Hello, What is the purpose of implementing the Observer Pattern if we can trigger an event easily? For example (from books), You have a "Forecaster" which notifies "Observable" when a...
1
by: aditi kauts | last post by:
Hi I am implementing security on Contact base smart card which follows scosta template. In card structure ef is directly under DF and DF is directly under MF. According to the template i am...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
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.