Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > HyperLink Bug

Reply
Thread Tools

HyperLink Bug

 
 
tshad
Guest
Posts: n/a
 
      08-01-2007
"gerry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> try : test = Page.ResolveUrl("displayCompanyOverview.aspx")


Great.

That works as long as I leave the ~ out.

I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what I
was looking for.

But what is the syntax to add it into the HyperLink object?

I tried:

<asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
runat="server"/><br>

and this gives me:

http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx ")%20%>

I also tried <% %> and had the same problem? Do I need sometype of Eval
syntax?

Thanks,

Tom
>
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "Teemu Keiski" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> It is public in ASP.NEt 2.0 but probably private in previous versions.
>>> You could try using Page.ResolveUrl in that case.
>>>
>>> (just note the PRB: http://support.microsoft.com/kb/811641 if you face
>>> issues with it)

>>
>> Actually, that one works but it still doesn't solve my problem.
>>
>> dim test as String
>> test = Page.ResolveUrl("~/displayCompanyOverview.aspx")
>> trace.warn("ResolveURL = " & test)
>>
>> Gives me:
>>
>> ResolveURL = /displayCompanyOverview.aspx
>>
>> That doesn't help the problem of the .aspx file coming from 2 different
>> folders.
>>
>> Thanks,
>>
>> Tom
>>>
>>> --
>>> Teemu Keiski
>>> AspInsider, ASP.NET MVP
>>> http://blogs.aspadvice.com/joteke
>>> http://teemukeiski.net
>>>
>>>
>>>
>>>
>>> "tshad" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I looked at it and actually tried what it mentioned:
>>>>
>>>> string url = Page.ResolveClientUrl("~/Customers/Profile.aspx");
>>>>
>>>> But get a message:
>>>>
>>>> 'System.Web.UI.Control.Private Function ResolveClientUrl(relativeUrl As
>>>> String) As String' is not accessible in this context because it is
>>>> 'Private'.
>>>>
>>>> I still have the problem that if this is how a Hyperlink works - to
>>>> make a generic control that uses Hyperlinks is going to be difficult
>>>> when I can't call it from different locations.
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>
>>>> "Teemu Keiski" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> For the record here too:
>>>>>
>>>>> Programmatically resolving ~ URL's to the Virtual Root using
>>>>> ResolveURL()
>>>>> http://www.geekzilla.co.uk/View35445C1B-E1DA-45C7-AFE5- .htm
>>>>>
>>>>> --
>>>>> Teemu Keiski
>>>>> AspInsider, ASP.NET MVP
>>>>> http://blogs.aspadvice.com/joteke
>>>>> http://teemukeiski.net
>>>>>
>>>>> "Teemu Keiski" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>> There says on following that page
>>>>>>
>>>>>> Note:
>>>>>> The URL returned by this method is relative to the folder
>>>>>> containing the source file in which the control is instantiated.
>>>>>> Controls that inherit this property, such as UserControl and
>>>>>> MasterPage, will return a fully qualified URL relative to the
>>>>>> control.
>>>>>>
>>>>>> --
>>>>>> Teemu Keiski
>>>>>> AspInsider, ASP.NET MVP
>>>>>> http://blogs.aspadvice.com/joteke
>>>>>> http://teemukeiski.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> "tshad" <(E-Mail Removed)> wrote in message
>>>>>> news:(E-Mail Removed)...
>>>>>>> "Patrice" <http://www.chez.com/scribe/> wrote in message
>>>>>>> news:(E-Mail Removed)...
>>>>>>>> IMO the idea is that relative locations are relative to the element
>>>>>>>> that contains the link (that is relative to the user control
>>>>>>>> location if the relative location is included in a user control).
>>>>>>>
>>>>>>> I agree if you are talking about controls loading other controls or
>>>>>>> controls loading images. If relative, it should be relative to the
>>>>>>> control, as you say.
>>>>>>>
>>>>>>> But when jumping from page to page - paths should be relative to the
>>>>>>> page (not the control).
>>>>>>>
>>>>>>> Teemu mentioned (on another forum) that Hyperlink uses
>>>>>>> ResolveClientUrl to get the path. And Microsoft says in
>>>>>>> http://msdn2.microsoft.com/en-us/lib...clienturl.aspx
>>>>>>> that the path is relative to the current page (not the control).
>>>>>>> Parameters
>>>>>>> relativeUrl
>>>>>>> A URL relative to the current page
>>>>>>>
>>>>>>> I may be reading that wrong, but that is what it says and my trace
>>>>>>> shows the paths of the page as the location of the .aspx page.
>>>>>>>
>>>>>>>>
>>>>>>>> You could report this to connect.microsoft.com if you wish but IMO
>>>>>>>> it looks rather like a design decision that could be endlessly
>>>>>>>> discussed than a bug (I just said you could write some code, it
>>>>>>>> doesn't imply writing code means this is a bug).
>>>>>>>
>>>>>>> I shouldn't have called it a bug. But, IMHO, I would call it a
>>>>>>> design flaw.
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Tom
>>>>>>>>
>>>>>>>> --
>>>>>>>> Patrice
>>>>>>>>
>>>>>>>> "tshad" <(E-Mail Removed)> a écrit dans le message de news:
>>>>>>>> http://www.velocityreviews.com/forums/(E-Mail Removed)...
>>>>>>>>> "Patrice" <http://www.chez.com/scribe/> wrote in message
>>>>>>>>> news:%(E-Mail Removed)...
>>>>>>>>>> So it just look like that they kept the same behavior than for a
>>>>>>>>>> page that is if you say just "mylocation" in a link inside a
>>>>>>>>>> usercontrol, ASP.NET assumes that the location is relative to the
>>>>>>>>>> location of what provides the address (in this case the location
>>>>>>>>>> of the ASCX control).
>>>>>>>>>>
>>>>>>>>>> You could use code behind to provide your own address
>>>>>>>>>> resolution...
>>>>>>>>>
>>>>>>>>> So you are agreeing that it is a bug.
>>>>>>>>>
>>>>>>>>> I shouldn't have to do this. It should work like the
>>>>>>>>> Response.Redirect or <a> in calculating paths, I would think.
>>>>>>>>> Otherwise, trying to keep straight how to handle paths would be
>>>>>>>>> difficult - trying to figure out how to deal with paths in one
>>>>>>>>> control over another. There is no consistancy here.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>>
>>>>>>>>> Tom
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Patrice
>>>>>>>>>>
>>>>>>>>>> "tshad" <(E-Mail Removed)> a écrit dans le message de news:
>>>>>>>>>> %(E-Mail Removed)...
>>>>>>>>>>>I had posted this problem earlier and just noticed that the
>>>>>>>>>>>Hyperlink is the problem.
>>>>>>>>>>>
>>>>>>>>>>> Apparently, it doesn't figure out the path correctly. It uses
>>>>>>>>>>> the path of the file it is in, even if it is a control.
>>>>>>>>>>>
>>>>>>>>>>> I have 2 files "displayCompanyJobs.aspx" and
>>>>>>>>>>> "displayCompanyOverview.aspx" which are in both the folder
>>>>>>>>>>> "/jobseeker/" and "/employer/".
>>>>>>>>>>>
>>>>>>>>>>> I have a user control "displayCompanyJobs.ascx" that is in my
>>>>>>>>>>> /applicant/ folder.
>>>>>>>>>>>
>>>>>>>>>>> I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will
>>>>>>>>>>> load the user control /applicant/displayCompanyJobs.ascx. In my
>>>>>>>>>>> control, I have the following lines:
>>>>>>>>>>>
>>>>>>>>>>> <a href="displayCompanyOverview.aspx">anchor test</a><br>
>>>>>>>>>>> <asp:Hyperlink ID="test" Text="HyperLinkTest"
>>>>>>>>>>> NavigateUrl="displayCompanyOverview.aspx" runat="server"/><br>
>>>>>>>>>>>
>>>>>>>>>>> Both will put a link on the page. But the links are different.
>>>>>>>>>>> When you roll over the anchor (a href) it shows:
>>>>>>>>>>>
>>>>>>>>>>> http://www.stw.com/JobSeeker/display...yOverview.aspx which
>>>>>>>>>>> is correct. That is where the aspx files are.
>>>>>>>>>>>
>>>>>>>>>>> But if you roll over the Hyperlink you see:
>>>>>>>>>>>
>>>>>>>>>>> http://www.stw.com/applicant/display...yOverview.aspx which
>>>>>>>>>>> is not correct.
>>>>>>>>>>>
>>>>>>>>>>> If I call the .aspx page from the /employer/ folder:
>>>>>>>>>>>
>>>>>>>>>>> www.stw.com/employer/displayCompanyJobs.aspx
>>>>>>>>>>>
>>>>>>>>>>> When you roll over the anchor (a href) it shows:
>>>>>>>>>>>
>>>>>>>>>>> http://www.stw.com/employer/displayCompanyOverview.aspx which is
>>>>>>>>>>> correct. That is where the aspx files are.
>>>>>>>>>>>
>>>>>>>>>>> But if you roll over the Hyperlink you see:
>>>>>>>>>>>
>>>>>>>>>>> http://www.stw.com/applicant/display...yOverview.aspx which
>>>>>>>>>>> is not correct. So no matter where I call the control from the
>>>>>>>>>>> Hyperlinks will always try to jump to the same folder as the
>>>>>>>>>>> Controls.
>>>>>>>>>>>
>>>>>>>>>>> If all my controls are in one folder and my aspx pages are in a
>>>>>>>>>>> different folder, you obviously want to go to the folder where
>>>>>>>>>>> the aspx files are. Anchors (a href) and Response.Redirect do it
>>>>>>>>>>> correctly and Hyperlinks do not.
>>>>>>>>>>>
>>>>>>>>>>> This appears to be a bug since Hyperlinks translate into an link
>>>>>>>>>>> (anchor) tag and you would expect it to work the same.
>>>>>>>>>>>
>>>>>>>>>>> Why is this and is there a way around this.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>>
>>>>>>>>>>> Tom
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
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
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink davetichenor ASP .Net 1 10-30-2006 02:57 PM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink Dave ASP .Net Datagrid Control 0 10-21-2006 07:48 PM
Hyperlink w/ImageUrl bug? Leigh Kendall ASP .Net 8 08-19-2003 01:47 PM
Dynamically Hyperlink and Event Handler for the Hyperlink ? Ken ASP .Net Datagrid Control 1 08-15-2003 11:38 PM



Advertisments