473,406 Members | 2,769 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,406 software developers and data experts.

Hyperlink control in user control

Hello,

I am having what I think is a problem with hyperlinks in user controls. My
usercontrol is in my Controls/NavControls directory. The page that I have
consuming the control is in my Pages/PageInfo/ directory.

My control, PageNav.ascx has an asp:hyperlink control on it that sets the
NavigateUrl property dynamically. I want to set it to a local reference,
something like: <a href="page2.aspx">Page2</aor having it generate to:
http://mysite/Pages/PageInfo/page2.aspx would work as well.

However, it seems that the hyperlink is generating is to the Control's
directory, instead of the consuming page directory.. ie it is rendering to <a
href="http://mysite/Controls/NavControls/page2.aspx">Page2</a... which is
not a valid page.

Does anyone know if there are any properties I can set to make this work
like I want? Or is there some code involved that I'd have to put in.

Thanks
Mar 22 '07 #1
2 1334
"cgambino" <cg******@discussions.microsoft.comwrote in message
news:AF**********************************@microsof t.com...
I am having what I think is a problem with hyperlinks in user controls.
My
usercontrol is in my Controls/NavControls directory. The page that I
have
consuming the control is in my Pages/PageInfo/ directory.

My control, PageNav.ascx has an asp:hyperlink control on it that sets the
NavigateUrl property dynamically. I want to set it to a local reference,
something like: <a href="page2.aspx">Page2</aor having it generate to:
http://mysite/Pages/PageInfo/page2.aspx would work as well.

However, it seems that the hyperlink is generating is to the Control's
directory, instead of the consuming page directory.. ie it is rendering to
<a
href="http://mysite/Controls/NavControls/page2.aspx">Page2</a... which
is
not a valid page.

Does anyone know if there are any properties I can set to make this work
like I want? Or is there some code involved that I'd have to put in.
<a href="../../Pages/PageInfo/page2.aspx">Page2</a>
Mar 22 '07 #2
I agree with Mark Rae, but to elaborate a bit more....

The behavior that you are describing is by design and should be what
you want. You want all the paths to be relative from the User
Control, and *not* from the containing page. That way you can re-use
your user control on multiple pages without breaking all the paths.
Sound right?

So, what people normally do is use the ".." operator to back up one
directory as in href="..\images\myimage.gif".

See also: the tilde "~" as used in paths and the "ResolveUrl() and
ResolveClientUrl() methods". You shouldn't have to use these though.
You can also start a path with "/" to say that your are starting from
the root of your website. The root might change, though, if you
deploy to different servers/environments.
Mar 22 '07 #3

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

Similar topics

3
by: hermawih | last post by:
Please help . I want to load the contents of another rtf document by double-clicking the words . Chapter1.rtf Chapter2.rtf Chapter3.rtf ....
0
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...
6
by: sck10 | last post by:
Hello, Can you control the window attributes (toolbar, scrollbars, left and right exc.) when using the hyperlink control as you would when using javascript? For examle, I am using the...
5
by: JerryK | last post by:
Hi, I am trying to put a hyperlink to a .cer (certificate) file on a form. Normally (on a ,htm page) when the user clicks on the hyperlink, the file is not recognized and the user is given the...
19
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...
3
by: sloesch | last post by:
I am working with VS.net 2003, framework 1.1, developing with VB.net, and ASP.net, and I would like to know how you can create a dynamic hyperlink on the fly to a document stored in a SQL database?...
10
by: David Thielen | last post by:
Hi; I have help html pages for each page of my ASP.NET webapp. So for the page datasource.aspx, I have help\datasource.htm. Bu what I want when the hyperlink is clicked, for it to look for the...
20
by: tshad | last post by:
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...
2
by: BobLaughland | last post by:
Hi There, I need a control on my site that is a hyperlink style control, but it must, 1) Have a property that can hold where the hyperlink is pointing to. (e.g. like the NavigateUrl property...
5
LAD
by: LAD | last post by:
Using Access 2003 on Windows 2000. My Skill Level: Med Low (Some VBA, okay with Access) Form: Single View - based on Query of single Table to sort by field. Application: Dealers email 'contract...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
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.