By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

referencing an anchor from within a usercontrol (ascx)

P: n/a
Hi,

I am trying to reference an anchor in a user control with a url. This
worked in 1.1 but no longer works in 2.0.

The ascx control is located in a "/include" folder

If you have a hyperlink control and you assign the navigateurl property =
"../#anchor" whereby you want to add this # reference to the current url the
url ends up with the #anchor twice.

In other words, instead of getting:
http://www.myweb.com?somevar=abc#anchor
it renders
http://www.myweb.com?somevar=abc#anchor#anchor

if i leave off the "../" it renders with one "#anchor" but as
http://www.myweb.com/include/#anchor

which is incorrect for what i need to do.

Any ideas why this is coming up twice and how to fix it. I don't want to
have to move the includes out of the include folder and into the root
directory of the web and then have to fix every other locations where they
are referenced with the "../"

Thanks,

Gary

Dec 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Gary,

Welcome to MSDN newsgroup.
Regarding on the referencing Anchor in asp.net Uesrcontrol from its
container page question, based on my research, we can use the following
means to reference the anchor in self page:

1. directly put teh anchor name in the hyperlijnk's href attribute like:

<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="#ar2">Anchor2</asp:HyperLink><br />

2 Or we can also inlclude the fullname of the current page together with
the anchor info. e.g:

<asp:HyperLink ID="HyperLink3" runat="server"
NavigateUrl="~/AnchorTestPage.aspx#ar3">Anchor3</asp:HyperLink><br
/>
Hope helps.Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "gary" <ga********@nospam.nospam>
| Subject: referencing an anchor from within a usercontrol (ascx)
| Date: Mon, 19 Dec 2005 19:20:32 -0500
| Lines: 34
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <O#**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: user237.209.42.44.dsli.com 209.42.44.237
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365841
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
|
| I am trying to reference an anchor in a user control with a url. This
| worked in 1.1 but no longer works in 2.0.
|
| The ascx control is located in a "/include" folder
|
| If you have a hyperlink control and you assign the navigateurl property =
| "../#anchor" whereby you want to add this # reference to the current url
the
| url ends up with the #anchor twice.
|
| In other words, instead of getting:
| http://www.myweb.com?somevar=abc#anchor
| it renders
| http://www.myweb.com?somevar=abc#anchor#anchor
|
| if i leave off the "../" it renders with one "#anchor" but as
| http://www.myweb.com/include/#anchor
|
| which is incorrect for what i need to do.
|
| Any ideas why this is coming up twice and how to fix it. I don't want to
| have to move the includes out of the include folder and into the root
| directory of the web and then have to fix every other locations where they
| are referenced with the "../"
|
| Thanks,
|
| Gary
|
|
|
|
|
|

Dec 20 '05 #2

P: n/a
Hello Steven

The first one does not work, the "#ar2" alone renders a double "#ar2#ar2".

Building the entire link from the servervariables collection, including the
query_string and then adding the "#ar2" does work.

It's got to be a bug!
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:t4**************@TK2MSFTNGXA02.phx.gbl...
Hi Gary,

Welcome to MSDN newsgroup.
Regarding on the referencing Anchor in asp.net Uesrcontrol from its
container page question, based on my research, we can use the following
means to reference the anchor in self page:

1. directly put teh anchor name in the hyperlijnk's href attribute like:

<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="#ar2">Anchor2</asp:HyperLink><br />

2 Or we can also inlclude the fullname of the current page together with
the anchor info. e.g:

<asp:HyperLink ID="HyperLink3" runat="server"
NavigateUrl="~/AnchorTestPage.aspx#ar3">Anchor3</asp:HyperLink><br
/>
Hope helps.Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "gary" <ga********@nospam.nospam>
| Subject: referencing an anchor from within a usercontrol (ascx)
| Date: Mon, 19 Dec 2005 19:20:32 -0500
| Lines: 34
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <O#**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: user237.209.42.44.dsli.com 209.42.44.237
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365841
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
|
| I am trying to reference an anchor in a user control with a url. This
| worked in 1.1 but no longer works in 2.0.
|
| The ascx control is located in a "/include" folder
|
| If you have a hyperlink control and you assign the navigateurl property
=
| "../#anchor" whereby you want to add this # reference to the current url
the
| url ends up with the #anchor twice.
|
| In other words, instead of getting:
| http://www.myweb.com?somevar=abc#anchor
| it renders
| http://www.myweb.com?somevar=abc#anchor#anchor
|
| if i leave off the "../" it renders with one "#anchor" but as
| http://www.myweb.com/include/#anchor
|
| which is incorrect for what i need to do.
|
| Any ideas why this is coming up twice and how to fix it. I don't want
to
| have to move the includes out of the include folder and into the root
| directory of the web and then have to fix every other locations where
they
| are referenced with the "../"
|
| Thanks,
|
| Gary
|
|
|
|
|
|

Dec 20 '05 #3

P: n/a
Seems a bit strange. Does the problem occur if you do not use Usercontrol,
directly put some anchors in a page and use some hyperlinks to pointed to
those anchors? Also, if convenient, would you attach a simple page (and
usercontrol if necessary) so that i can perform some tests on my side?

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "gary" <ga********@nospam.nospam>
| References: <O#**************@TK2MSFTNGP09.phx.gbl>
<t4**************@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: referencing an anchor from within a usercontrol (ascx)
| Date: Tue, 20 Dec 2005 10:59:01 -0500
| Lines: 103
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <eH*************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: user237.209.42.44.dsli.com 209.42.44.237
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365983
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello Steven
|
| The first one does not work, the "#ar2" alone renders a double "#ar2#ar2".
|
| Building the entire link from the servervariables collection, including
the
| query_string and then adding the "#ar2" does work.
|
| It's got to be a bug!
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:t4**************@TK2MSFTNGXA02.phx.gbl...
| > Hi Gary,
| >
| > Welcome to MSDN newsgroup.
| > Regarding on the referencing Anchor in asp.net Uesrcontrol from its
| > container page question, based on my research, we can use the following
| > means to reference the anchor in self page:
| >
| > 1. directly put teh anchor name in the hyperlijnk's href attribute like:
| >
| > <asp:HyperLink ID="HyperLink2" runat="server"
| > NavigateUrl="#ar2">Anchor2</asp:HyperLink><br />
| >
| > 2 Or we can also inlclude the fullname of the current page together with
| > the anchor info. e.g:
| >
| > <asp:HyperLink ID="HyperLink3" runat="server"
| >
NavigateUrl="~/AnchorTestPage.aspx#ar3">Anchor3</asp:HyperLink><br
| > />
| >
| >
| > Hope helps.Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | From: "gary" <ga********@nospam.nospam>
| > | Subject: referencing an anchor from within a usercontrol (ascx)
| > | Date: Mon, 19 Dec 2005 19:20:32 -0500
| > | Lines: 34
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <O#**************@TK2MSFTNGP09.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: user237.209.42.44.dsli.com 209.42.44.237
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:365841
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Hi,
| > |
| > | I am trying to reference an anchor in a user control with a url. This
| > | worked in 1.1 but no longer works in 2.0.
| > |
| > | The ascx control is located in a "/include" folder
| > |
| > | If you have a hyperlink control and you assign the navigateurl
property
| > =
| > | "../#anchor" whereby you want to add this # reference to the current
url
| > the
| > | url ends up with the #anchor twice.
| > |
| > | In other words, instead of getting:
| > | http://www.myweb.com?somevar=abc#anchor
| > | it renders
| > | http://www.myweb.com?somevar=abc#anchor#anchor
| > |
| > | if i leave off the "../" it renders with one "#anchor" but as
| > | http://www.myweb.com/include/#anchor
| > |
| > | which is incorrect for what i need to do.
| > |
| > | Any ideas why this is coming up twice and how to fix it. I don't
want
| > to
| > | have to move the includes out of the include folder and into the root
| > | directory of the web and then have to fix every other locations where
| > they
| > | are referenced with the "../"
| > |
| > | Thanks,
| > |
| > | Gary
| > |
| > |
| > |
| > |
| > |
| > |
| >
|
|
|

Dec 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.