Link to home
Start Free TrialLog in
Avatar of Steve
SteveFlag for United States of America

asked on

User Control and Subdirectories

I created a menu for my C# web app as a .ascx user control file that is then called from all of the other files of the app.  I have recently begun adding subdirectories and reorganizing the code files into the appropriate subdirectory, and modifing the code as necessary to reflect the file move.  I'm now having an issue with my user control.  The control works great the first time you click on a menu option, which takes you to a subdirectory.  (The user control is in the parent directory of the application.)  The problem comes in when you use the menu beyond the first time.  It's appending the HREF with the name of the subdirectory each time the menu is clicked.

For instance, I have a subdirectory named reveal.  When I click on the menu the first time, it takes me to ./reveal/reveal.aspx.  When I click on it a second time, it tries to go to ./reveal/reveal/reveal.aspx.  How do I stop that from happening?
.acsx user control menu code file:
 
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="menu.ascx.cs" Inherits="revealAccess.menu" %>
<head>
    <title>Menu</title>
    <link rel="stylesheet" type="text/css" href="menu.css" />
    <link rel="stylesheet" type="text/css" href="../menu.css" />
</head>
<body>
    <ul id="menu">
        <li><a href="#">New Request</a>
            <ul>
                <li><a href="./reveal/reveal.aspx">Reveal</a></li>
            </ul>
        </li>
        <li><a href="#">Pending Requests</a>
            <ul>
                <li><a href="./reveal/pendingRevealRequests.aspx">Reveal</a></li>
            </ul>
        </li>
        <li><a href="#">Approved Requests</a>
            <ul>
                <li><a href="./reveal/approvedRevealRequests.aspx">Reveal</a></li>
            </ul>
        </li>
        <li><a href="#">Completed Requests</a>
            <ul>
                <li><a href="./reveal/completedRevealRequests.aspx">Reveal</a></li>
            </ul>
        </li>
    </ul>
    <br />
    <br />
</body>
 
 
 
.aspx file calling the menu:
 
<%@ Register TagPrefix="uc1" TagName="menu" Src="../menu.ascx" %>
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="reveal.aspx.cs" Inherits="revealAccess._Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Application Access Request - Reveal</title>
    <link rel="stylesheet" type="text/css" href="../site.css" />
</head>
<body>
    <form id="reveal" method="post" runat="server">
    <uc1:menu ID="Menu" runat="server"></uc1:menu>
    <div id="content">

Open in new window

Avatar of ToddBeaulieu
ToddBeaulieu
Flag of United States of America image

Can you just change the relative path to something based off the app root?

"." means start here.

The last time I struggled with paths I documented it here:

http://toddbeaulieu.spaces.live.com/blog/cns!2A634C4E26554001!284.entry
ASKER CERTIFIED SOLUTION
Avatar of Steve
Steve
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial