?
Solved

User Control and Subdirectories

Posted on 2009-07-08
2
Medium Priority
?
220 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

Independent Software Vendors: 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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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 …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

801 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