473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Problem when using anchor in user control

Hi,
When adding an anchor (which is runat="server") in a user control, the
link generated will be based on the user control location and not on
the page which is using the control location.
For example, if the user control is located in an include folder, here
is what I will get:
<a href="include/home.aspx">
instead of
<a href="home.aspx">

I can't use "~/home.aspx" as a value for the href property because the
result I want is <a href="home.aspx"and not
<a href="/home.aspx">

Any suggestion ?

Thanks in advance

Mar 8 '07 #1
3 2829
You could use a server hyperlink control instead of an Html anchor
<asp:Hyperlink ID="myHyperlink" runat="server" NavigateUrl="~/home.aspx"></asp:Hyperlink>
HTH

Kostas Pantos
Hi,
When adding an anchor (which is runat="server") in a user control, the
link generated will be based on the user control location and not on
the page which is using the control location.
For example, if the user control is located in an include folder, here
is what I will get:
<a href="include/home.aspx">
instead of
<a href="home.aspx">
I can't use "~/home.aspx" as a value for the href property because the
result I want is <a href="home.aspx"and not
<a href="/home.aspx">
Any suggestion ?

Thanks in advance

Mar 8 '07 #2
On 8 mar, 11:57, Konstantinos Pantos <kpan...@dolnet.grwrote:
You could use a server hyperlink control instead of an Html anchor
<asp:Hyperlink ID="myHyperlink" runat="server" NavigateUrl="~/home.aspx"></asp:Hyperlink>
HTH

Kostas Pantos
Hi,
When adding an anchor (which is runat="server") in a user control, the
link generated will be based on the user control location and not on
the page which is using the control location.
For example, if the user control is located in an include folder, here
is what I will get:
<a href="include/home.aspx">
instead of
<a href="home.aspx">
I can't use "~/home.aspx" as a value for the href property because the
result I want is <a href="home.aspx"and not
<a href="/home.aspx">
Any suggestion ?
Thanks in advance- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
I've got the same problem with an hyperlink control. The result I want
is <a href="home.aspx"and not
<a href="/home.aspx"(no dash before "home.aspx")

Mar 8 '07 #3
Are you going to change the location of home.aspx at runtime?
If not, then all you have to do is specify at your control the exact path
to your home.aspx.
<asp:Hyperlink ID="myHyperlink" runat="server" NavigateUrl="~/ExactPath/home.aspx"></asp:Hyperlink>
Your user control will always link to the right place because at runtime
it will replace ~ with "http://host/application".
HTH

Kostas Pantos
On 8 mar, 11:57, Konstantinos Pantos <kpan...@dolnet.grwrote:
>You could use a server hyperlink control instead of an Html anchor
<asp:Hyperlink ID="myHyperlink" runat="server"
NavigateUrl="~/home.aspx"></asp:Hyperlink>
HTH
Kostas Pantos
>>Hi,
When adding an anchor (which is runat="server") in a user control,
the
link generated will be based on the user control location and not on
the page which is using the control location.
For example, if the user control is located in an include folder,
here
is what I will get:
<a href="include/home.aspx">
instead of
<a href="home.aspx">
I can't use "~/home.aspx" as a value for the href property because
the
result I want is <a href="home.aspx"and not
<a href="/home.aspx">
Any suggestion ?
Thanks in advance- Masquer le texte des messages pricidents -
- Afficher le texte des messages pricidents -
I've got the same problem with an hyperlink control. The result I want
is <a href="home.aspx"and not
<a href="/home.aspx"(no dash before "home.aspx")

Mar 8 '07 #4

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

Similar topics

7
by: neverstill | last post by:
hi- I have <a> tags in my DataList. For the href property, I want to do something like this: <a href='~/Default.aspx?show=Support&disp=Faq&p=<%# DataBinder.Eval(Container.DataItem, "name")%>'...
1
by: Roshawn | last post by:
Hi All, I have created a web user control. This control mimics the numeric pagers seen on many online bookstores. I made this user control using the Repeater. It is populated dynamically. ...
3
by: Asad | last post by:
Hi, I am trying to write my first Windows application using VB.NET and I am having some difficulties designing the UI. Basically its one Windows Form with 4 menus on the top (no drop downs)....
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
3
by: gary | last post by:
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...
10
by: elibol | last post by:
Hi, Is there an event that fires when the back or forward button on a browser is pressed? I need an event to fire when someone clicks the back or forward button after an anchor has been set. ...
3
by: Greg | last post by:
This works properly: 1. Create a new Form and set it's size to 229, 474. 2. Drag a Panel to the form and set the following properties: Size = 216, 438 Location = 3,1 Anchor = Top, Bottom...
5
by: lamxing | last post by:
Hi, I've come across a strange problem with the WinForm's sizing. I've designed a WinForm and it runs fine on my computer and some other PCs. But when I was trying to run the app under some PCs...
1
by: praveenb000 | last post by:
Hi every one, I designed a web page, having horizontal menu using UL and LI tags; I need to be set rollover effect for a menu items. whenever user hover on a menu item, the entire...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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...

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.