473,385 Members | 1,341 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,385 software developers and data experts.

link URL confusion

I'm confused about how to code a link button to go to the page I need
(asp.net 2.0)

My root is "Website1"

Here's the layout for the purposes of this question:

Website1 (folder)
masterpage.master (in the root)

Admin (folder off the root)
SendMail.aspx (uses the master)

LoggedInUsers (folder off the root)
EditLoginInfo.aspx (uses the master)

Default.aspx (this is in the root and also uses the master)

Most of the pages are in the root including the master page. All the pages
in the system use that master page.

On the master page I have a line of text like this:

<a href="LoggedInUsers/EditLoginInfo.aspx">Edit Login Info</a>

When I'm on the Default.aspx page and click the link, it goes to the page I
expect it to. However, when I'm on the SendMail.aspx page and I click the
"Edit Login Info" link, I get the error: "The resource cannot be found"
Requested URL: /Website1/Admin/LoggedInUsers/EditLoginInfo.aspx

I understand why because obviously there's no such folder layout as
/Website1/Admin/LoggedInUsers/ so it's not finding the page but I don't know
what to change to make it work. If I change the link to read

<a href="~/LoggedInUsers/EditLoginInfo.aspx">Edit Login Info</a>

I get the same error: "The resource cannot be found"

and:

Requested URL: /Website1/Admin/~/LoggedInUsers/EditLoginInfo.aspx

Now what's really confusing to me is if I use a LinkButton instead of just
text with href, and set the PostBackUrl in the button as follows:

PostBackUrl="~/LoggedInUsers/EditLoginInfo.aspx"

then that link button works fine no matter where I am in the site. Doesn't
matter what folder I'm in, it always finds the page I need.

Do I have to use link buttons with PostBackUrl whenever I'm dealing with
master pages and subfolders or is there a way to use href in text and get
this to work right?

I hope I've made the problem clear enough.

Thanks,

Keith


Mar 6 '08 #1
2 1555
I should point out that if I put the root in the <a href ... like this:

<a href="/Wesite1/LoggedInUsers/EditLoginInfo.aspx">Edit Login Info</a>

It works fine, but everthing I read says it's bad practice to hardcode the
root anywhere.

Keith
Mar 6 '08 #2
Hello Keith,

You can use the <asp:hyperlink /control to add a link to a different page.
it has a property in which you can set the url using the ~/path notation.
The hyperlink control will automatically resolve the url to teh correct value
depending on which page is using the masterpage. Just like your LinkButton
is doing. Another thing you could try is to set the runat="server" attribute
on your <a href=".."tags.

--
Jesse Houwing
jesse.houwing at sogeti.nl
I'm confused about how to code a link button to go to the page I need
(asp.net 2.0)

My root is "Website1"

Here's the layout for the purposes of this question:

Website1 (folder)
masterpage.master (in the root)
Admin (folder off the root)
SendMail.aspx (uses the master)
LoggedInUsers (folder off the root)
EditLoginInfo.aspx (uses the master)
Default.aspx (this is in the root and also uses the master)

Most of the pages are in the root including the master page. All the
pages in the system use that master page.

On the master page I have a line of text like this:

<a href="LoggedInUsers/EditLoginInfo.aspx">Edit Login Info</a>

When I'm on the Default.aspx page and click the link, it goes to the
page I expect it to. However, when I'm on the SendMail.aspx page and I
click the "Edit Login Info" link, I get the error: "The resource
cannot be found" Requested URL:
/Website1/Admin/LoggedInUsers/EditLoginInfo.aspx

I understand why because obviously there's no such folder layout as
/Website1/Admin/LoggedInUsers/ so it's not finding the page but I
don't know what to change to make it work. If I change the link to
read

<a href="~/LoggedInUsers/EditLoginInfo.aspx">Edit Login Info</a>

I get the same error: "The resource cannot be found"

and:

Requested URL: /Website1/Admin/~/LoggedInUsers/EditLoginInfo.aspx

Now what's really confusing to me is if I use a LinkButton instead of
just text with href, and set the PostBackUrl in the button as follows:

PostBackUrl="~/LoggedInUsers/EditLoginInfo.aspx"

then that link button works fine no matter where I am in the site.
Doesn't matter what folder I'm in, it always finds the page I need.

Do I have to use link buttons with PostBackUrl whenever I'm dealing
with master pages and subfolders or is there a way to use href in text
and get this to work right?

I hope I've made the problem clear enough.

Thanks,

Keith

Mar 7 '08 #3

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

Similar topics

4
by: Dodo | last post by:
Is it possible to create a link that can post a value to an ASP page without java?
7
by: lawrence | last post by:
In my style sheet I've set the links like this: a:link{ text-decoration:none; } I did that for the pseudo classes and I also did that for the image tag. Yet there are still link lines...
14
by: Don G | last post by:
Within the menu for my site, I have inserted 'class="current"' within the link for the current page. So the link looks somthing link: <li><a href="index.php" class="current">Home</a></li> The...
5
by: Harry | last post by:
CSS Description: Table contains a column of td cells with links. Achieved: 1. Entire link cells highlight when hovered. 2. The entire area of these cells are clickable. Problem:
5
by: sriram | last post by:
I have the following: class BSA { ... ... ... ... public: enum VRGAttrId {
26
by: Harrie | last post by:
Hi, After Brian mentioned the use for <link rel=..> for navigational purposes in another thread, I've been looking into it and found that HTML 3.2 has two other recognized link types than HTML...
3
by: Alex Shturm | last post by:
Hi, I am trying to activate incremental link using VC7 (.NET 2003) on a pretty big project (executable size is more than 100Mb, and it gets linked from several dozen of libraries and object...
26
by: Mica Cooper | last post by:
Hi, I need to pass some info in a javascript submit. <a href="javascript:document.formName.submit();">Submit Form</a> Normally a link would do page.jsp?x1=1&x2=2&x3=3 and you would pull x1,...
11
by: mosscliffe | last post by:
I am trying to create a link to a file, which I can then use in an HTML page. The system is Linux on a hosted web service, running python 2.3. Other than that I have no knowledge of the system....
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.