HyperLink Bug [英] HyperLink Bug

查看:62
本文介绍了HyperLink Bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前发过这个问题,只是注意到超链接是

问题。


显然,它并没有找到路径正确。即使它是一个控件,它也使用它所在文件的路径




我有2个文件displayCompanyJobs.aspx和displayCompanyOverview.aspx

,它们都在文件夹/ jobseeker /中。和/雇主/。


我有一个用户控件displayCompanyJobs.ascx在我的/ applicant /

文件夹中。


我打电话给 www.stw.com/jobseeker/displayCompanyJobs.aspx ,它将加载

用户控件/applicant/displayCompanyJobs.ascx。在我的控制下,我有以下几行




< a href =" displayCompanyOverview.aspx"> anchor test< / a>< ; br>

< asp:Hyperlink ID =" test" Text =" HyperLinkTest"

NavigateUrl =" displayCompanyOverview.aspx" runat =" server" />< br>


两者都会在页面上放置一个链接。但链接是不同的。当你在
翻转锚点(一个href)时,它会显示:

http://www.stw.com/JobSeeker/display...yOverview.aspx 这是正确的。

那是aspx文件是。


但是如果你滚动超链接,你会看到:

http://www.stw.com/applicant/display...yOverview.aspx 这不是

正确。


如果我从/ employer /文件夹中调用.aspx页面:

www.stw.com/employer/displayCompanyJobs.aspx


滚动时锚点(a href)显示:

http: //www.stw.com/employer/displayCompan yOverview.aspx 哪个是正确的。

这就是aspx文件的位置。


但是如果翻过超链接,你会看到:< > http://www.stw.com/applicant /display...yOverview.aspx 这不是

正确。因此,无论我从何处调用超链接的控件,

总是尝试跳转到与控件相同的文件夹。


如果我的所有控件都在一个文件夹和我的aspx页面在不同的

文件夹中,你显然想要转到aspx文件所在的文件夹。

锚点(一个href)和响应。重定向做得正确,超链接做

没有。


这似乎是一个错误,因为超链接转换为链接(锚)

标签,你会希望它的工作原理相同。


为什么会这样,有办法解决这个问题。


谢谢,


Tom

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

推荐答案

这不是错误。你没有考虑到的是

超链接服务器控件的实际行为方式,这与你期望的b $ b不同。你无法将它与普通的< ahtml元素进行比较,因为

服务器上的< aelement完全没有做任何事情。


不同之处在于超链接服务器控件是试图保持链接相对于用户控件的
。这意味着你将获得完全不同的路径。这样做是正确的,因为,如果

你只是链接到一个普通文件而且不需要服务器

控制调整网址,你不需要它,可以只使用< ahtml

元素。


在用户控件中使用超链接控件时,你有想象一下如何获得你想要的路径

。我通常会发现将它写在

应用程序根目录中的问题最少。在这种情况下,使用〜/在url的开头用/ b
写出来,例如:〜/ mydirectory / mypage.aspx

这将弄明白相对于应用程序根目录的路径

(请记住,它是应用程序的根目录,而不是域名,尽管如果它是

也是根应用程序他们是一样的。

-

希望这会有所帮助,

Mark Fitzpatrick

Microsoft FrontPage MVP 199 ?-2006。 2007年及以后

" tshad" < t@home.com在留言中写道

新闻:%2 **************** @ TK2MSFTNGP06.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 <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.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...

>我之前发过这个问题,只是注意到超链接是问题所在。


显然,它没有要弄清楚路径是否正确。即使它是一个控件,它也使用它所在文件的路径




我有2个文件displayCompanyJobs.aspx和displayCompanyOverview.aspx

,它们都在文件夹/ jobseeker /中。和/雇主/。


我有一个用户控件displayCompanyJobs.ascx在我的/ applicant /

文件夹中。


我打电话给 www.stw.com/jobseeker/displayCompanyJobs.aspx ,它将加载

用户控件/applicant/displayCompanyJobs.ascx。在我的控制下,我有以下几行:


< a href =" displayCompanyOverview.aspx"> anchor test< / a>< ; br>

< asp:Hyperlink ID =" test" Text =" HyperLinkTest"

NavigateUrl =" displayCompanyOverview.aspx" runat =" server" />< br>


两者都会在页面上放置一个链接。但链接是不同的。当你在
翻转锚点(一个href)时,它会显示:

http://www.stw.com/JobSeeker/display...yOverview.aspx 这是正确的。

那是aspx文件是。


但是如果你滚动超链接,你会看到:

http://www.stw.com/applicant/display...yOverview.aspx 这不是

正确。


如果我从/ employer /文件夹中调用.aspx页面:

www.stw.com/employer/displayCompanyJobs.aspx


滚动时锚点(a href)显示:

http: //www.stw.com/employer/displayCompanyOvervi ew.aspx 这是正确的。

这就是aspx文件的位置。


但是如果翻过超链接,你会看到:< > http://www.stw.com/applicant /display...yOverview.aspx 这不是

正确。因此,无论我从何处调用超链接的控件,

总是尝试跳转到与控件相同的文件夹。


如果我的所有控件都在一个文件夹和我的aspx页面在不同的

文件夹中,你显然想要转到aspx文件所在的文件夹。

锚点(一个href)和响应。重定向做得正确,超链接做

没有。


这似乎是一个错误,因为超链接转换为链接(锚)

标签,你会希望它的工作原理相同。


为什么会这样,有办法解决这个问题。


谢谢,


Tom
>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



所以看起来他们保持的行为与

的页面,如果你只是说mylocation在用户控件内的一个链接中,ASP.NET

假设该位置是相对于提供

地址的位置(在这种情况下是ASCX控件的位置) )。


您可以使用后面的代码来提供您自己的地址解析...


-

帕特里斯


" tshad" <t@home.comaécritdansle message de news:

%2 **************** @ TK2MSFTNGP06.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...

--
Patrice

"tshad" <t@home.coma écrit dans le message de news:
%2****************@TK2MSFTNGP06.phx.gbl...

>我之前发布过这个问题,只是注意到超链接是问题所在。


显然,它没有正确地找出路径。即使它是一个控件,它也使用它所在文件的路径




我有2个文件displayCompanyJobs.aspx和displayCompanyOverview.aspx

,它们都在文件夹/ jobseeker /中。和/雇主/。


我有一个用户控件displayCompanyJobs.ascx在我的/ applicant /

文件夹中。


我打电话给 www.stw.com/jobseeker/displayCompanyJobs.aspx ,它将加载

用户控件/applicant/displayCompanyJobs.ascx。在我的控制下,我有以下几行:


< a href =" displayCompanyOverview.aspx"> anchor test< / a>< ; br>

< asp:Hyperlink ID =" test" Text =" HyperLinkTest"

NavigateUrl =" displayCompanyOverview.aspx" runat =" server" />< br>


两者都会在页面上放置一个链接。但链接是不同的。当你在
翻转锚点(一个href)时,它会显示:

http://www.stw.com/JobSeeker/display...yOverview.aspx 这是正确的。

那是aspx文件是。


但是如果你滚动超链接,你会看到:

http://www.stw.com/applicant/display...yOverview.aspx 这不是

正确。


如果我从/ employer /文件夹中调用.aspx页面:

www.stw.com/employer/displayCompanyJobs.aspx


滚动时锚点(a href)显示:

http: //www.stw.com/employer/displayCompanyOvervi ew.aspx 这是正确的。

这就是aspx文件的位置。


但是如果翻过超链接,你会看到:< > http://www.stw.com/applicant /display...yOverview.aspx 这不是

正确。因此,无论我从何处调用超链接的控件,

总是尝试跳转到与控件相同的文件夹。


如果我的所有控件都在一个文件夹和我的aspx页面在不同的

文件夹中,你显然想要转到aspx文件所在的文件夹。

锚点(一个href)和响应。重定向做得正确,超链接做

没有。


这似乎是一个错误,因为超链接转换为链接(锚)

标签,你会希望它的工作原理相同。


为什么会这样,有办法解决这个问题。


谢谢,


Tom
>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



在ASP.NET上的同一主题上链接同一用户的主题论坛
http://forums.asp.net /p/1141040/1835683.aspx#1835683


-

Teemu Keiski

AspIns ider,ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


" tshad" < t@home.com在留言中写道

新闻:%2 **************** @ TK2MSFTNGP06.phx.gbl ...
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.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...

>我之前发过这个问题,只是注意到超链接是问题所在。


显然,它没有要弄清楚路径是否正确。即使它是一个控件,它也使用它所在文件的路径




我有2个文件displayCompanyJobs.aspx和displayCompanyOverview.aspx

,它们都在文件夹/ jobseeker /中。和/雇主/。


我有一个用户控件displayCompanyJobs.ascx在我的/ applicant /

文件夹中。


我打电话给 www.stw.com/jobseeker/displayCompanyJobs.aspx ,它将加载

用户控件/applicant/displayCompanyJobs.ascx。在我的控制下,我有以下几行:


< a href =" displayCompanyOverview.aspx"> anchor test< / a>< ; br>

< asp:Hyperlink ID =" test" Text =" HyperLinkTest"

NavigateUrl =" displayCompanyOverview.aspx" runat =" server" />< br>


两者都会在页面上放置一个链接。但链接是不同的。当你在
翻转锚点(一个href)时,它会显示:

http://www.stw.com/JobSeeker/display...yOverview.aspx 这是正确的。

那是aspx文件是。


但是如果你滚动超链接,你会看到:

http://www.stw.com/applicant/display...yOverview.aspx 这不是

正确。


如果我从/ employer /文件夹中调用.aspx页面:

www.stw.com/employer/displayCompanyJobs.aspx


滚动时锚点(a href)显示:

http: //www.stw.com/employer/displayCompanyOvervi ew.aspx 这是正确的。

这就是aspx文件的位置。


但是如果翻过超链接,你会看到:< > http://www.stw.com/applicant /display...yOverview.aspx 这不是

正确。因此,无论我从何处调用超链接的控件,

总是尝试跳转到与控件相同的文件夹。


如果我的所有控件都在一个文件夹和我的aspx页面在不同的

文件夹中,你显然想要转到aspx文件所在的文件夹。

锚点(一个href)和响应。重定向做得正确,超链接做

没有。


这似乎是一个错误,因为超链接转换为链接(锚)

标签,你会希望它的工作原理相同。


为什么会这样,有办法解决这个问题。


谢谢,


Tom
>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



这篇关于HyperLink Bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆