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

Discussion in 'ASP .Net' started by Keith G Hicks, Feb 29, 2008.

  1. 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
     
    Keith G Hicks, Feb 29, 2008
    #1
    1. Advertising

  2. 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:

    <a href="~/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><br>

    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
    >
    >
     
    Keith G Hicks, Feb 29, 2008
    #2
    1. Advertising

  3. "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
     
    Mark Rae [MVP], Feb 29, 2008
    #3
  4. 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.

    Requested URL: /Website1/LoggedInUsers/Home.aspx

    ---------------------------------------------------------------------------

    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
    Version:2.0.50727.42


    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, Feb 29, 2008
    #4
  5. "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
     
    Mark Rae [MVP], Feb 29, 2008
    #5
  6. 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?

    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, Feb 29, 2008
    #6
  7. "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?


    The easiest thing to do would be to use webcontrols e.g. <asp:HyperLink> or,
    as you say, to add runat="server" to the HTML controls and to use the tilde
    (~) character as shorthand for the virtual root rather than hard-coding it
    by name:
    http://www.google.co.uk/search?sour...rlz=1T4GZEZ_en-GBGB252GB252&q="ASP.NET" tilde


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Feb 29, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lars Pedersen

    Usercontrol in webforms subfolder

    Lars Pedersen, Jul 6, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    384
    Lars Pedersen
    Jul 6, 2003
  2. joe
    Replies:
    0
    Views:
    425
  3. Jeff Johnson
    Replies:
    6
    Views:
    3,757
    tharadk
    Jul 24, 2009
  4. Philippe Meunier
    Replies:
    3
    Views:
    1,720
    John Saunders
    Oct 18, 2003
  5. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,125
Loading...

Share This Page