Solved

User Control and Subdirectories

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now