Click here to Skip to main content
15,905,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i'm retrieving menu from database using GenericHandler. This works fine but i need to resolve the Url since from of the links are not in the same folder. Here is a little code .


what is need to resolve is the "this.Url" which is been returned from my Generic Handler class. Anyway round this please??


What I have tried:

JavaScript
<script type="text/javascript">
             $(document).ready(function () {
                 $.ajax({
                     url: "<%: ResolveUrl("~/MenuHandler.ashx")%>",
                     method: 'GET',
                     dataType: 'json',
                     success: function (data) {
                         buildMenu($('#menu'), data)
                         $('#menu').menu();
                     }
                 });


                 function buildMenu(parent, items) {
                     $.each(items, function () {
                         var li = $('<li class="treeview"><a href="' + this.Url + '"><span>' + this.MenuDescription + '</span><span class="pull-right-container">^__i class="fa fa-angle-left pull-right"><i/></span></a></li>');
                         li.appendTo(parent);
                         if (this.List && this.List.length > 0) {
                             var ul = $('<ul class="treeview-menu"></ul>');
                             var newli = $('<li></li>')
                             ul.appendTo(li);
                             buildMenu(ul, this.List);
                         }
                     });
                 }
             });
    </script>
Posted
Comments
F-ES Sitecore 28-Jun-17 4:43am    
What do you mean by "resolve" it?
Mcbaloo 28-Jun-17 6:33am    
something like <%:ResolveUrl("")%> . With the above code i dropped, if i navigate to another page in a different folder from my current page, i can't return back to the previous page because of Url issue..
Kornfeld Eliyahu Peter 28-Jun-17 8:55am    
Your code is wrong, there is a problem with the single/double quotes...
I also have a hard time to see the connection between the code and the comment you had above...

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



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