473,909 Members | 4,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HyperLink Bug

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 "displayCompany Jobs.aspx" and "displayCompany Overview.aspx"
which are in both the folder "/jobseeker/" and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my /applicant/
folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load the
user control /applicant/displayCompanyJ obs.ascx. In my control, I have the
following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperlin k ID="test" Text="HyperLink Test"
NavigateUrl="di splayCompanyOve rview.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.Redire ct 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
Aug 1 '07 #1
20 3018
This is not a bug. What you have not taken into account is the way a
hyperlink server control actually behaves, which is different from what you
are expecting. You can't compare it to a regular <ahtml element since
there is absolutely nothing being done by the server on the <aelement.

The difference lies in the fact that the hyperlink server control is
attempting to keep the link relative to the user control. That means you'll
get a completely different path. It is doing it's job correctly because, if
you were just linking to an ordinary file and didn't need to have the server
control adjust the url, you wouldn't need it and could just use an <ahtml
element.

When using a hyperlink control in a user control, you have to figure on how
to get the path as you would like it. I usually find writing it against the
application root poses the least problems. In this case, write it out by
using a ~/ at the beginning of the url such as: ~/mydirectory/mypage.aspx
and that will figure out the path relative to the root of the application
(remember, it's the root of the application, not the domain although if it's
also a root application they are the same).
--
Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond
"tshad" <t@home.comwrot e in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>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 "displayCompany Jobs.aspx" and "displayCompany Overview.aspx"
which are in both the folder "/jobseeker/" and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my /applicant/
folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load the
user control /applicant/displayCompanyJ obs.ascx. In my control, I have
the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperlin k ID="test" Text="HyperLink Test"
NavigateUrl="di splayCompanyOve rview.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.Redire ct 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

Aug 1 '07 #2
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...

--
Patrice

"tshad" <t@home.coma écrit dans le message de news:
%2************* ***@TK2MSFTNGP0 6.phx.gbl...
>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 "displayCompany Jobs.aspx" and "displayCompany Overview.aspx"
which are in both the folder "/jobseeker/" and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my /applicant/
folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load the
user control /applicant/displayCompanyJ obs.ascx. In my control, I have
the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperlin k ID="test" Text="HyperLink Test"
NavigateUrl="di splayCompanyOve rview.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.Redire ct 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

Aug 1 '07 #3
Linking same user's thread on same subject on ASP.NET Forums
http://forums.asp.net/p/1141040/1835683.aspx#1835683

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"tshad" <t@home.comwrot e in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>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 "displayCompany Jobs.aspx" and "displayCompany Overview.aspx"
which are in both the folder "/jobseeker/" and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my /applicant/
folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load the
user control /applicant/displayCompanyJ obs.ascx. In my control, I have
the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperlin k ID="test" Text="HyperLink Test"
NavigateUrl="di splayCompanyOve rview.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.Redire ct 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

Aug 1 '07 #4
"Mark Fitzpatrick" <ma******@fitzm e.comwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
This is not a bug. What you have not taken into account is the way a
hyperlink server control actually behaves, which is different from what
you are expecting. You can't compare it to a regular <ahtml element
since there is absolutely nothing being done by the server on the <a>
element.
I agree that it isn't an <aelement but it equates into one.
>
The difference lies in the fact that the hyperlink server control is
attempting to keep the link relative to the user control. That means
you'll get a completely different path. It is doing it's job correctly
because, if you were just linking to an ordinary file and didn't need to
have the server control adjust the url, you wouldn't need it and could
just use an <ahtml element.
I also agree that it is trying to keep the link relative to the user
control. That is fine for images and buttons or textfiles that always in
the same folder. But that makes it useless for links to different pages
that are relative to the page you are in. The control is not the page you
are in. It is called by a page. Obviously the <atag and
Response.Redire ct understand this.

It isn't doing its job correctly if it is figuring out paths if it is
handling the paths differently than everything else. In every other place
if I say url="display.as px" it would assume that path is the same as the
original path of the page that called it. A control should not be using the
location of the control (otherwise since Hyperlink is a control why not use
the location of the Hyperlink control itself).

Here is the trace of the page:

PATH_INFO /JobSeeker/displayCompanyJ obs.aspx
PATH_TRANSLATED C:\Inetpub\wwwr oot\stw\JobSeek er\displayCompa nyJobs.aspx
SCRIPT_NAME /JobSeeker/displayCompanyJ obs.aspx
URL /JobSeeker/displayCompanyJ obs.aspx

All the paths are the path of the page itself. Nowhere do you see
/applicant/

The only way I can figure out how to make this work is to change all my 50
pages or so that use a hyperlink and figure out where it came from (because
it can be different) and add that NavigationURL or change all my Hyperlinks
to LinkButtons and use the Response.Redire ct to do it correctly. Both are a
pain.
>
When using a hyperlink control in a user control, you have to figure on
how to get the path as you would like it. I usually find writing it
against the application root poses the least problems. In this case, write
it out by using a ~/ at the beginning of the url such as:
~/mydirectory/mypage.aspx and that will figure out the path relative to
the root of the application (remember, it's the root of the application,
not the domain although if it's also a root application they are the
same).
And how do I do this from the control where mydirectory can be different.
How would I do it in my case where mydirectory is either /jobseeker/ or
/applicant/? I tried using the ~ like "~/displayCompanyO verview.aspx" and
of course it couldn't find it.

Thanks,

Tom
>

--
Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond
"tshad" <t@home.comwrot e in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>>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 "displayCompany Jobs.aspx" and
"displayCompan yOverview.aspx" which are in both the folder "/jobseeker/"
and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my /applicant/
folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load the
user control /applicant/displayCompanyJ obs.ascx. In my control, I have
the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperli nk ID="test" Text="HyperLink Test"
NavigateUrl="d isplayCompanyOv erview.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.Redire ct 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


Aug 1 '07 #5
"Patrice" <http://www.chez.com/scribe/wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
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.Redire ct or
<ain 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" <t@home.coma écrit dans le message de news:
%2************* ***@TK2MSFTNGP0 6.phx.gbl...
>>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 "displayCompany Jobs.aspx" and
"displayCompan yOverview.aspx" which are in both the folder "/jobseeker/"
and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my /applicant/
folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load the
user control /applicant/displayCompanyJ obs.ascx. In my control, I have
the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperli nk ID="test" Text="HyperLink Test"
NavigateUrl="d isplayCompanyOv erview.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.Redire ct 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


Aug 1 '07 #6
Tom,
A control should not be using the location of the control (otherwise since
Hyperlink is a control why not use the location of the Hyperlink control
itself).
That's not how it is. You are wanting it to be a certain way, but the .Net
Framework does not behave that way.
It isn't doing its job correctly if it is figuring out paths if it is
handling the paths differently than everything else. In every other place
if I say url="display.as px" it would assume that path is the same as the
original path of the page that called it. A control should not be using
the location of the control (otherwise since Hyperlink is a control why
not use the location of the Hyperlink control itself).

It IS doing it's job correctly. You're making an assumption though on how
you expect it to behave, which is not correct. User controls keep liks
relative to them for a good reason, they are designed to be included in more
than one page. If I use a user control to contain a header graphic (or
similar element) for each and every page in my web site and need to maintain
a consitent behavior, I need the hyperlinks and image paths to be relative
to that particular user control and not the page.

You're also mixing control terminology. A Hyperlink is a control yes, but it
is not a User Control. A Hyperlink is a Server Control, which has a totally
different behavior and goal than a User Control, which is what you have.

Links and other elements need to be according to the container that they are
in. If you put a Hyperlink Control in a page, you expect it to be relative
to the page. If you put it into a User Control, you expect it to be relative
to the User Control.
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.Redire ct do it correctly and Hyperlinks do
not.
Anchors are not the same as a Hyperlink server control. A plain old <a>
element is not handled by your server at all and is, instead handled by the
browser. It's your browser that sends back a request for a file at a
particular location. The Response.Redire ct does it as you are expecting
because it is an entirely different process all together. You can't compare
these two items to the behavior of the Hyperlink control, or any other
server control for that matter.

I can understand the frustration but you have to forget about the expected
behavior and figure out how and why it really behaves that way. That's the
way it behaves and there are darned good reasons for it to behave that way.
There are going to be a lot of things like this in the .Net Framework, but
you can't argue them away as bugs. This behavior has been in the Framework
since the 1.0 version and is still there for very, very good reasons. Give
some good examination for the reasons and once you have some more experience
working with them you'll find this behavior a very handy tool.
--
Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond


"tshad" <t@home.comwrot e in message
news:Ou******** ******@TK2MSFTN GP05.phx.gbl...
"Mark Fitzpatrick" <ma******@fitzm e.comwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
>This is not a bug. What you have not taken into account is the way a
hyperlink server control actually behaves, which is different from what
you are expecting. You can't compare it to a regular <ahtml element
since there is absolutely nothing being done by the server on the <a>
element.

I agree that it isn't an <aelement but it equates into one.
>>
The difference lies in the fact that the hyperlink server control is
attempting to keep the link relative to the user control. That means
you'll get a completely different path. It is doing it's job correctly
because, if you were just linking to an ordinary file and didn't need to
have the server control adjust the url, you wouldn't need it and could
just use an <ahtml element.

I also agree that it is trying to keep the link relative to the user
control. That is fine for images and buttons or textfiles that always in
the same folder. But that makes it useless for links to different pages
that are relative to the page you are in. The control is not the page you
are in. It is called by a page. Obviously the <atag and
Response.Redire ct understand this.

It isn't doing its job correctly if it is figuring out paths if it is
handling the paths differently than everything else. In every other place
if I say url="display.as px" it would assume that path is the same as the
original path of the page that called it. A control should not be using
the location of the control (otherwise since Hyperlink is a control why
not use the location of the Hyperlink control itself).

Here is the trace of the page:

PATH_INFO /JobSeeker/displayCompanyJ obs.aspx
PATH_TRANSLATED C:\Inetpub\wwwr oot\stw\JobSeek er\displayCompa nyJobs.aspx
SCRIPT_NAME /JobSeeker/displayCompanyJ obs.aspx
URL /JobSeeker/displayCompanyJ obs.aspx

All the paths are the path of the page itself. Nowhere do you see
/applicant/

The only way I can figure out how to make this work is to change all my 50
pages or so that use a hyperlink and figure out where it came from
(because it can be different) and add that NavigationURL or change all my
Hyperlinks to LinkButtons and use the Response.Redire ct to do it
correctly. Both are a pain.
>>
When using a hyperlink control in a user control, you have to figure on
how to get the path as you would like it. I usually find writing it
against the application root poses the least problems. In this case,
write it out by using a ~/ at the beginning of the url such as:
~/mydirectory/mypage.aspx and that will figure out the path relative to
the root of the application (remember, it's the root of the application,
not the domain although if it's also a root application they are the
same).

And how do I do this from the control where mydirectory can be different.
How would I do it in my case where mydirectory is either /jobseeker/ or
/applicant/? I tried using the ~ like "~/displayCompanyO verview.aspx" and
of course it couldn't find it.

Thanks,

Tom
>>

--
Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond
"tshad" <t@home.comwrot e in message
news:%2******* *********@TK2MS FTNGP06.phx.gbl ...
>>>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 "displayCompany Jobs.aspx" and
"displayCompa nyOverview.aspx " which are in both the folder "/jobseeker/"
and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my
/applicant/ folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load
the user control /applicant/displayCompanyJ obs.ascx. In my control, I
have the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperlin k ID="test" Text="HyperLink Test"
NavigateUrl=" displayCompanyO verview.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.Redire ct 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



Aug 1 '07 #7
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).

You could report this to connect.microso ft.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).

--
Patrice

"tshad" <t@home.coma écrit dans le message de news:
ej************* *@TK2MSFTNGP03. phx.gbl...
"Patrice" <http://www.chez.com/scribe/wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>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.Redire ct or
<ain 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" <t@home.coma écrit dans le message de news:
%2************ ****@TK2MSFTNGP 06.phx.gbl...
>>>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 "displayCompany Jobs.aspx" and
"displayCompa nyOverview.aspx " which are in both the folder "/jobseeker/"
and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my
/applicant/ folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load
the user control /applicant/displayCompanyJ obs.ascx. In my control, I
have the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperlin k ID="test" Text="HyperLink Test"
NavigateUrl=" displayCompanyO verview.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.Redire ct 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



Aug 1 '07 #8
I stand corrected.

I shouldn't have called it a bug. But I think that the behavior is not
consistant with other parts of the .Net Framework.

I also agree that Paths are different depending on use.

I know that if a control loads another control the path (when not absolute)
should be relative to the controls (as you say). Also, if loading a Graphic
I would assume that you would use something like: "/images/graphic.jpg" if
you have all your graphics in one location and if you want to use a Graphic
specific to that control and use "graphic.jp g", I would assume the graphic
would be in the same location as the control.

But when you are Hyperlinking to another page (Redirecting), I would assume
that "page.aspx" would mean that the path would be relative to the calling
page not the calling control. You absolutely cannot put all your controls
in one location, if you wanted to, and use relative paths. Now if this is
the behavior, which it appears to be, then I will have to deal with it as
you say.

As I mentioned below, you can't use the "~/mydirectory/mypage.aspx" if the
control can be called by pages in different locations. Or am I missing
something.

As far as I can tell, I will have to go to any page that has a Hyperlink on
it and change it to something like:

<asp:Hyperlin k ID="test" Text="HyperLink Test" NavigateUrl=<%#
request.ServerV ariables("PATH_ INFO").Substrin g(0,request.Ser verVariables("P ATH_INFO").Last IndexOf("/")+1)
& "displayCompany Overview.aspx" %runat="server"/><br>

But I can't get that to work either. It equates to:
/JobSeeker/displayCompanyO verview.aspx.

It doesn't show as a link but as just the text: HyperLinkTest.

Thanks,

Tom

"Mark Fitzpatrick" <ma******@fitzm e.comwrote in message
news:Ow******** ******@TK2MSFTN GP03.phx.gbl...
Tom,
>A control should not be using the location of the control (otherwise
since Hyperlink is a control why not use the location of the Hyperlink
control itself).

That's not how it is. You are wanting it to be a certain way, but the .Net
Framework does not behave that way.
>It isn't doing its job correctly if it is figuring out paths if it is
handling the paths differently than everything else. In every other
place if I say url="display.as px" it would assume that path is the same
as the original path of the page that called it. A control should not be
using the location of the control (otherwise since Hyperlink is a control
why not use the location of the Hyperlink control itself).


It IS doing it's job correctly. You're making an assumption though on how
you expect it to behave, which is not correct. User controls keep liks
relative to them for a good reason, they are designed to be included in
more than one page. If I use a user control to contain a header graphic
(or similar element) for each and every page in my web site and need to
maintain a consitent behavior, I need the hyperlinks and image paths to be
relative to that particular user control and not the page.

You're also mixing control terminology. A Hyperlink is a control yes, but
it is not a User Control. A Hyperlink is a Server Control, which has a
totally different behavior and goal than a User Control, which is what you
have.

Links and other elements need to be according to the container that they
are in. If you put a Hyperlink Control in a page, you expect it to be
relative to the page. If you put it into a User Control, you expect it to
be relative to the User Control.
>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.Redire ct do it correctly and Hyperlinks do
not.

Anchors are not the same as a Hyperlink server control. A plain old <a>
element is not handled by your server at all and is, instead handled by
the browser. It's your browser that sends back a request for a file at a
particular location. The Response.Redire ct does it as you are expecting
because it is an entirely different process all together. You can't
compare these two items to the behavior of the Hyperlink control, or any
other server control for that matter.

I can understand the frustration but you have to forget about the expected
behavior and figure out how and why it really behaves that way. That's the
way it behaves and there are darned good reasons for it to behave that
way. There are going to be a lot of things like this in the .Net
Framework, but you can't argue them away as bugs. This behavior has been
in the Framework since the 1.0 version and is still there for very, very
good reasons. Give some good examination for the reasons and once you have
some more experience working with them you'll find this behavior a very
handy tool.
--
Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond


"tshad" <t@home.comwrot e in message
news:Ou******** ******@TK2MSFTN GP05.phx.gbl...
>"Mark Fitzpatrick" <ma******@fitzm e.comwrote in message
news:uA******* *******@TK2MSFT NGP02.phx.gbl.. .
>>This is not a bug. What you have not taken into account is the way a
hyperlink server control actually behaves, which is different from what
you are expecting. You can't compare it to a regular <ahtml element
since there is absolutely nothing being done by the server on the <a>
element.

I agree that it isn't an <aelement but it equates into one.
>>>
The difference lies in the fact that the hyperlink server control is
attempting to keep the link relative to the user control. That means
you'll get a completely different path. It is doing it's job correctly
because, if you were just linking to an ordinary file and didn't need to
have the server control adjust the url, you wouldn't need it and could
just use an <ahtml element.

I also agree that it is trying to keep the link relative to the user
control. That is fine for images and buttons or textfiles that always in
the same folder. But that makes it useless for links to different pages
that are relative to the page you are in. The control is not the page
you are in. It is called by a page. Obviously the <atag and
Response.Redir ect understand this.

It isn't doing its job correctly if it is figuring out paths if it is
handling the paths differently than everything else. In every other
place if I say url="display.as px" it would assume that path is the same
as the original path of the page that called it. A control should not be
using the location of the control (otherwise since Hyperlink is a control
why not use the location of the Hyperlink control itself).

Here is the trace of the page:

PATH_INFO /JobSeeker/displayCompanyJ obs.aspx
PATH_TRANSLATE D C:\Inetpub\wwwr oot\stw\JobSeek er\displayCompa nyJobs.aspx
SCRIPT_NAME /JobSeeker/displayCompanyJ obs.aspx
URL /JobSeeker/displayCompanyJ obs.aspx

All the paths are the path of the page itself. Nowhere do you see
/applicant/

The only way I can figure out how to make this work is to change all my
50 pages or so that use a hyperlink and figure out where it came from
(because it can be different) and add that NavigationURL or change all my
Hyperlinks to LinkButtons and use the Response.Redire ct to do it
correctly. Both are a pain.
>>>
When using a hyperlink control in a user control, you have to figure on
how to get the path as you would like it. I usually find writing it
against the application root poses the least problems. In this case,
write it out by using a ~/ at the beginning of the url such as:
~/mydirectory/mypage.aspx and that will figure out the path relative to
the root of the application (remember, it's the root of the application,
not the domain although if it's also a root application they are the
same).

And how do I do this from the control where mydirectory can be different.
How would I do it in my case where mydirectory is either /jobseeker/ or
/applicant/? I tried using the ~ like "~/displayCompanyO verview.aspx"
and of course it couldn't find it.

Thanks,

Tom
>>>

--
Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond
"tshad" <t@home.comwrot e in message
news:%2****** **********@TK2M SFTNGP06.phx.gb l...
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 "displayCompany Jobs.aspx" and
"displayComp anyOverview.asp x" which are in both the folder
"/jobseeker/" and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my
/applicant/ folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load
the user control /applicant/displayCompanyJ obs.ascx. In my control, I
have the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperli nk ID="test" Text="HyperLink Test"
NavigateUrl= "displayCompany Overview.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.Redire ct 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



Aug 1 '07 #9
"Patrice" <http://www.chez.com/scribe/wrote in message
news:Oa******** *****@TK2MSFTNG P06.phx.gbl...
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 ResolveClientUr l 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.microso ft.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" <t@home.coma écrit dans le message de news:
ej************* *@TK2MSFTNGP03. phx.gbl...
>"Patrice" <http://www.chez.com/scribe/wrote in message
news:%2******* *********@TK2MS FTNGP05.phx.gbl ...
>>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.Redire ct
or <ain 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" <t@home.coma écrit dans le message de news:
%2*********** *****@TK2MSFTNG P06.phx.gbl...
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 "displayCompany Jobs.aspx" and
"displayComp anyOverview.asp x" which are in both the folder
"/jobseeker/" and "/employer/".

I have a user control "displayCompany Jobs.ascx" that is in my
/applicant/ folder.

I call www.stw.com/jobseeker/displayCompanyJobs.aspx, which will load
the user control /applicant/displayCompanyJ obs.ascx. In my control, I
have the following lines:

<a href="displayCo mpanyOverview.a spx">anchor test</a><br>
<asp:Hyperli nk ID="test" Text="HyperLink Test"
NavigateUrl= "displayCompany Overview.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.Redire ct 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



Aug 1 '07 #10

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

Similar topics

1
3396
by: Badboy36 | last post by:
Hello user from googlegroups, i made a microsoft access database with front and backend. i created the backend in microsoft access97. for the frontend i made two versions (one for microsoft access 97 and the other one for microsoft acess 2000/2002). my problem is in a field with a hyperlink , which i selected in a table. this hyperlink refer to microsoft word documents on our intranet. i enter the hyperlink in a formular (right...
0
550
by: Ryan Harvey | last post by:
Hi all, I have written a web user control that contains a repeater control. the ItemTemplate for this control is basically 6 Hyperlinks in a row, that are dynamically allocated one of 7 gif images as the ImageURL of the Hyperlink. When a load the page with the controls on it works fine, but sometimes the images are broken, but if i hit refresh i get random selections of the gifs appearing and not appearing. if i hit Back button to a page...
5
6698
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below but here is the snippet of my asp:hyperlink object; <asp:HyperLink NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(Conta iner.DataItem,"CLIENTREF")%> ID="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,...
9
2725
by: Leon | last post by:
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks. <asp:datalist id="DataList1" runat="server" RepeatColumns="4"> <ItemTemplate> <asp:HyperLink id=HyperLink1 ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" & Container.DataItem("PathToDisplyPic"))%>' NavigateUrl='<%#
10
1951
by: david | last post by:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it. Do you have ideas about it? Thanks.
19
3572
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred to here as page_2). I need to cache the value of the link's text (hyperlink.text property) so that I can use it in the page_load event of page_2. I've thought of using a hidden field and then calling Request.Form("hdnClickedLinkText") in the...
8
3808
by: Nathan Sokalski | last post by:
I have several System.Web.UI.WebControls.HyperLink Controls which I want to display as rollover images. I know how to make these manually using the <a> and <img> tags or the <a> tag and a System.Web.UI.WebControls.Image Control or a HyperLink and Image Controls, but the onMouseOver and onMouseOut attributes must be in the <img> tag. If I were to use the HyperLink's ImageUrl property and add the attributes using the...
2
2445
by: Andy | last post by:
Hi, This is one of those things I thought should e easy... I'm programatically trying to set the navigateURL property in a hyperlink in the headertemplate of a repeater, but always get the following error "Object reference not set to an instance of an object." when referencing the hypermink in the following line.. hypAuthors.NavigateUrl = "http://www.microsoft.com"
10
3027
by: sierra7 | last post by:
I'm trying to create a form where a user enters a document reference number and then clicks a command button to add a hyperlink to the document, via a file picker. Thanks to Adezii's excellent article http://bytes.com/topic/access/answers/725778-inserting-hyperlink-into-table I can manage to create a hyperlink to the document and store it in the table, but it is the full hyperlink path not the reference number of the document that is...
0
11346
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...
1
11046
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,...
0
10538
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8097
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
5938
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...
0
6138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3357
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.