Solved

User Control and Subdirectories

Posted on 2009-07-08
2
216 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How come this regular expression allows "e"? 14 45
C# LINQ ForEach() question 6 55
ASP.NET (VB) return a record 2 40
Data organization issue 7 22
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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