Solved

User Control and Subdirectories

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IIS issues - Convert to Application - APS.NET v4.0 3 37
Gridview selected row 9 47
Code works but it's slow 28 71
imap mails 1 24
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 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