Terry

Terry

  • NA
  • 148
  • 0

Routing doesn't work with anchor and/or asp:HyperLink !!!!

Jun 3 2015 7:41 AM
Hi,
   in my asp.net 4.5 WebForms app, I have implemented Routing. In mt RouteConfig.cs I have added :
routes.MapPageRoute("Import", "Import/{ImportType}", "~/Views/ImportData.aspx");
 When I am using the route like below, it is working perfectly well :
Response.RedirectToRoute("Import", new { ImportType = "Channel" });
 I have a menu, where I want to redirect to the above route. So I used :
<li class="menu-green"><a runat="server" href='<%# GetRouteUrl("Import", new { ImportType = "Inquiry"} ) %>'>Import</a></li>
Instead of <a> I tried using <asp:Hyperlink>, but none of them works.  On checking the source at execution, I found that anchor/hyperlink tag has no href or is blank.
 
When I made it as LinkButton & implemeted onClick event in code behind & used the Response.Redirect, that is again working.
 
 Why I am not able to redirect it thru anchor at hyperlink in the menu  ??
 
Any ideas. Is my GetRouteUrl code wrong Or do I need to add any thing in aspx ??