Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear all,
I am using Menu Using JQuery it is working very well but there is small problem.In my project there are some pages in a folder and when
I click on menu, it navigate to correct page which is in folder but after i click on other menu it creates wrong Url
* my menu control is on master page
on a route content is : MemberInformation.aspx, FillMemberInformation.aspx, AND "Admin" Folder
in admin folder there is a page named AddPackage.aspx
when i request to MemberInformation.aspx, FillMemberInformation.aspx pages it redirects well.as well as it works well when request to addPackage.aspx

eg.:http://localhost:1037/VehicleServicing/MemberInformation.aspx
now I am on addPackage.aspx which is in admin folder and if i request to MemberInformation.aspx, it try to redirect path which contains admin folder in path

eg:http://localhost:1037/VehicleServicing/Admin/MemberInformation.aspx
======Server Error in '/VehicleServicing' Application.
======The resource cannot be found.


here is my code

<tr style="background-color: #00CC00; height: 30px">
                     <td valign="bottom">
                         <ul id="nav">
                             <li><a href="#">Parent 01</a></li>
                             <li><a href="#" class="selected">Master</a>
                                 <ul>
                                     <li><a href="MemberInformation.aspx">Member</a></li>
                                     <li><a href="Admin/AddPackage.aspx">Package</a></li>
                                     <li><a href="#">Worker</a></li>
                                     <li><a href="#">User</a></li>
                                 </ul>
                                 <div class="clear">
                                 </div>
                             </li>
                             <li><a href="#">Transactions</a>
                                 <ul>
                                     <li><a href="#">Transactions 1</a></li>
                                     <li><a href="#">Transactions 2</a></li>
                                     <li><a href="#">Transactions 3</a></li>
                                     <li><a href="#">Transactions 4</a></li>
                                     <li><a href="#">Transactions 5</a></li>
                                     <li><a href="#">Transactions 6</a></li>
                                     <li><a href="#">Transactions 7</a></li>
                                 </ul>
                                 <div class="clear">
                                 </div>
                             </li>
                             <li><a href="#">Report</a></li>
                         </ul>
                         <div class="clear">
                         </div>
                     </td>
                 </tr>


This is the jquery script:

<script type="text/javascript">
$(document).ready(function () {
    $('#nav li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);
        },
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);
        }
    );
});
    </script>


Why it is happening please help me.
Posted
Updated 5-May-11 3:28am
v3
Comments
Karthik. A 5-May-11 9:27am    
Formatted the question

1 solution

You are using relative paths in your menu. Convert them to absolute and you will likely get better results.

What is happening is that when you are on the AddPackage page and you click on the menu to go to the Member page, the system is looking for it in the Admin folder instead of stepping back one level.

I haven't done this in a while, but I believe you can have your href begin with "/" to indicate an absolute path from the root of the web application.

Remember that even though the path you entered is correct from the Master Page location, the path will be relative to the location of the inheriting page.

XML
<a href="/MemberInformation.aspx">Member</a> <!-- Note the "/" prepended to the href -->
<a href="/Admin/AddPackage.aspx">Package</a>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900