Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Implementing ~/...

Reply
Thread Tools

Implementing ~/...

 
 
Jonathan Wood
Guest
Posts: n/a
 
      01-31-2007
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


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      01-31-2007
AFAIK this is Control.ResolveUrl. Try
http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...

"Jonathan Wood" <(E-Mail Removed)> a écrit dans le message de news:
uR$(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-31-2007
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" <(E-Mail Removed)> wrote in message
news:uR$(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-31-2007
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:eIvK$%(E-Mail Removed)...
> AFAIK this is Control.ResolveUrl. Try
> http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...
>
> "Jonathan Wood" <(E-Mail Removed)> a écrit dans le message de news:
> uR$(E-Mail Removed)...
>>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
>>
>>

>
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      01-31-2007
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" <(E-Mail Removed)> a écrit dans le
message de news: http://www.velocityreviews.com/forums/(E-Mail Removed)...
> 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:eIvK$%(E-Mail Removed)...
>> AFAIK this is Control.ResolveUrl. Try
>> http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...
>>
>> "Jonathan Wood" <(E-Mail Removed)> a écrit dans le message de news:
>> uR$(E-Mail Removed)...
>>>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
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Jonathan Wood
Guest
Posts: n/a
 
      01-31-2007
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" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:uR$(E-Mail Removed)...
>>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
>>
>>

>
>



 
Reply With Quote
 
Jonathan Wood
Guest
Posts: n/a
 
      01-31-2007
Yep, that did it. Thanks!

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

"Patrice" <http://www.chez.com/scribe/> wrote in message
news:eIvK$%(E-Mail Removed)...
> AFAIK this is Control.ResolveUrl. Try
> http://msdn2.microsoft.com/en-us/lib...esolveurl.aspx...
>
> "Jonathan Wood" <(E-Mail Removed)> a écrit dans le message de news:
> uR$(E-Mail Removed)...
>>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
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing Interface Gomathi ASP .Net 1 11-17-2005 03:09 PM
Need help implementing a proj on SPARTAN3 Riccardo Fregonese VHDL 2 01-03-2005 01:21 PM
Implementing the CORDIC algorithm without using Real Data Type Johnsy Joseph VHDL 2 10-29-2004 10:49 AM
Implementing E1 - E3 Dev VHDL 1 09-09-2004 09:06 AM
vhdl for implementing pre-fetch and an instruction cache Eqbal Z VHDL 3 11-16-2003 06:07 AM



Advertisments