Click here to Skip to main content
15,891,677 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
All pages work correctly with routing but when selecting a menuitem (in masterpage) to go a page, it does not go to the selected page. When I enter product page with path localhost:3806/yarrow/Products/35 then click on home menuitem, it gives me this path localhost:3806/yarrow/Products/Default.aspx but correct path is localhost:3806/yarrow/Default.aspx. How to fix it please?

My sample code
VB
Sub RegisterRoutes(routes As System.Web.Routing.RouteCollection)
    routes.MapPageRoute("", "{DesignerID}", "~/PDesigners.aspx")
    routes.MapPageRoute("", "Products/{ProductID}", "~/Product.aspx")
End Sub

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs on application startup
    RegisterRoutes(System.Web.Routing.RouteTable.Routes)
End Sub


This code in my user control to get id dynamically

ASP.NET
<a href='<%# GetRouteUrl("",new with {.ProductID=Eval("ProductID")})%>' class="product-image">
           <img src='UploadedImages/Products/big/<%# EVAL("PictureID")%>' alt='<%# Eval("ProductTitle") %>'
               width="165" height="161" />
       <asp:Label ID="ProductImageLabel" runat="server" Text='<%# Eval("PictureID") %>' Visible="false" />
       </a>
Posted
Updated 29-Apr-13 5:33am
v2
Comments
sri senthil kumar 30-Apr-13 6:14am    
Can u post the code u have written for navigation to home page? May be we can help you.

1 solution

I would respectfully submit that localhost:3806/yarrow/Default.aspx is not, in fact, the correct path, and that the other is. I also think that your code may work as-is if you simply remove the tildes (~).
 
Share this answer
 

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