Solved

User Control and Subdirectories

Posted on 2009-07-08
2
218 Views
Last Modified: 2013-11-05
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

0
Comment
Question by:scross1276
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Expert Comment

by:ToddBeaulieu
ID: 24807916
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
0
 

Accepted Solution

by:
scross1276 earned 0 total points
ID: 24813968
Thanks for the tips ToddBeaulieu, I actually didn't know what the tilda (~) meant when used in a path.

I was able to fix my problem by adding the site name to the url paths.  In this case, the name is eforms, so when I prefixed /reveal/reveal.aspx with eforms, such as /eforms/reveal/reveal.aspx, then my user control menu works.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question