how do I navigate UP the directory tree from a subfolder?

I have a master page in my root. I have some other pages in subfolders. All
my navigation buttons are on the master page. When I click one of the
buttons that takes me to a page in a subfolder, that works fine. But then
when I click one of the buttons that's supposed to take me back up (to the
home page for example), it cannot find it. I understand why but I don't know
what to do to handle it. No idea. Could someone give me some specific info
on what to do? I tried searching online for an answer but I'm not even sure
what to search for. I'm sure this is a common thing so it can't be terribly
complicated.

Advertisements

I should mention that if I use an asp:button with the PostBackURL set to
something like "~/Home.aspx" it works but I have several img controls on the
page that have <a href="~/Home.aspx" ... in them as follows:

These are the buttons that don't work. THey function fine as long as I'm on
a page that's in the root, but as soon as I'm on a page that's in a
subdirectory, they throw an error.

Keith

"Keith G Hicks" <> wrote in message
news:#...
> asp.net 2.0
>
> I have a master page in my root. I have some other pages in subfolders.
All
> my navigation buttons are on the master page. When I click one of the
> buttons that takes me to a page in a subfolder, that works fine. But then
> when I click one of the buttons that's supposed to take me back up (to the
> home page for example), it cannot find it. I understand why but I don't
know
> what to do to handle it. No idea. Could someone give me some specific info
> on what to do? I tried searching online for an answer but I'm not even
sure
> what to search for. I'm sure this is a common thing so it can't be
terribly
> complicated.
>
> Thanks,
>
> Keith
>
>

Advertisements

"Keith G Hicks" <> wrote in message
news:...
> These are the buttons that don't work. They function fine as long as I'm
> on
> a page that's in the root, but as soon as I'm on a page that's in a
> subdirectory, they throw an error.

As a general rule in a technical newsgroup, there's very little point in
saying something like "they throw an error" if you don't actually tell the
group what the error is - I wrote some code this morning but, when I ran it,
it threw an error - what could the problem be...?

Don't answer people if all you can be is rude. I thought I stated the
problem pretty clearly in the original post and that because asp.net is new
to me I wasn't sure what to ask about exactly. I said "it cannot find the
page." I figured I didn't need to repeat that in my follow up. Iv'e been
writing and answering newsgroup messages for years in microsoft, borland and
various 3rd party tools. I don't need a scolding on how to be clear in a
post. I read posts all the time that are so far from clear that it's
laughable. Same for a lot fo the answers I see. I figured this is a common
issue and describing the fact that I have img controls on the master page
wiht <a href... /> links in them and that they can't navigate back up to the
root directory when on a page that's in a subfolder was super clear and
probably something that is easy for experienced asp.net folks (especially
MVP's) to solve. Does anyone have a helpful answer to my problem?

And if it helps, here's all the error info:

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure that
it is spelled correctly.

The page "Home.aspx" is actually in the root ("Website1"), not in the
"LoggedInUsers"
directory.

Keith

"Mark Rae [MVP]" <> wrote in message
news:...
> "Keith G Hicks" <> wrote in message
> news:...
>
> > These are the buttons that don't work. They function fine as long as I'm
> > on
> > a page that's in the root, but as soon as I'm on a page that's in a
> > subdirectory, they throw an error.
>
> As a general rule in a technical newsgroup, there's very little point in
> saying something like "they throw an error" if you don't actually tell the
> group what the error is - I wrote some code this morning but, when I ran
it,
> it threw an error - what could the problem be...?
>
> Please say what the error is that you're getting...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>

"Keith G Hicks" <> wrote in message
news:...
> And if it helps, here's all the error info:

It does.
> The resource cannot be found.
> Description: HTTP 404. The resource you are looking for (or one of its
> dependencies) could have been removed, had its name changed, or is
> temporarily unavailable. Please review the following URL and make sure
> that
> it is spelled correctly.
>
> Requested URL: /Website1/LoggedInUsers/Home.aspx

Looks very much like you have a relative addressing problem. One of the
resources that your page is looking for is not in the folder where the code
is expecting to find it...

Simplest way to track it down would be to do a View Source on the page where
the error occurs and inspect the URL paths in the HTML output...

That did the trick. I read that I also needed runat="server" in the img tags
for images that are on the master page otherwise they won't show up when
viewing a content page in a subfolder. That handled that problem. Before I
did that, the image MasterPageSideButtons/button1up.png didn't appear
because it's in a folder above the page i was viewing. Would something
similar handle the problem above (the one I originally posted about) or was
adding /MySiteRoot/ the correct thing to do?

Keith

"Mark Rae [MVP]" <> wrote in message
news:...
> "Keith G Hicks" <> wrote in message
> news:...
>
> > And if it helps, here's all the error info:
>
> It does.
>
> > The resource cannot be found.
> > Description: HTTP 404. The resource you are looking for (or one of its
> > dependencies) could have been removed, had its name changed, or is
> > temporarily unavailable. Please review the following URL and make sure
> > that
> > it is spelled correctly.
> >
> > Requested URL: /Website1/LoggedInUsers/Home.aspx
>
> Looks very much like you have a relative addressing problem. One of the
> resources that your page is looking for is not in the folder where the
code
> is expecting to find it...
>
> Simplest way to track it down would be to do a View Source on the page
where
> the error occurs and inspect the URL paths in the HTML output...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>

"Keith G Hicks" <> wrote in message
news:...
>I changed the url in the images so they include the root hard coded into
> them (I added /MySiteRoot/ to the href).
>
> <a href="/MySiteRoot/Home.aspx"
> onmouseover="setOverImg('1','');"onmouseout="setOutImg('1','');"target="">
> <img runat="server" src="MasterPageSideButtons/button1up.png" border="0"
> id="button1" vspace="1" hspace="1">
> </a>
>
> That did the trick. I read that I also needed runat="server" in the img
> tags
> for images that are on the master page otherwise they won't show up when
> viewing a content page in a subfolder. That handled that problem. Before I
> did that, the image MasterPageSideButtons/button1up.png didn't appear
> because it's in a folder above the page i was viewing. Would something
> similar handle the problem above (the one I originally posted about) or
> was
> adding /MySiteRoot/ the correct thing to do?

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!