c# - ASP.net WebForms - Using GetRouteUrl in markup -


I am trying to figure out how to use routing features with ASP.net 4.0 WebForms. I added a path to my path collection:

  zero Application_Start () {RegisterRoutes (RouteTable.Routes); } Zero Registration route (route collection route) {routes.MapPageRoute ("Near-way", "approx /", "~ / about.aspx"); }   

In my master page I tried to do the following:

  & asp: hyperlink id = "asdf" runat = "server" navigateUrl = ' & Lt;% = GetRouteUrl ("Near-way", New {})% & gt; & Gt; Test & lt; / Asdf>   

I got a compiler error: In the server tag, & lt;% ...% & gt; Constructs.

What is the correct way to create root URLs in a server control in a web form? I also need to include the following:

  & lt; ASP: Menu id = "Navigation Menu" Runat = "Server" CssClass = "menu" EnableViewState = "false" Include Styleball = "wrong" orientation = "horizontal" & gt; & Lt; Items & gt; & Lt; Asp: MenuItem NavigateUrl = "Route here" text = "home" /> & Lt; Asp: MenuItem NavigateUrl = "Ruth here" text = "about" /> & Lt; / Item & gt; & Lt; / ASP: Menu & gt;    

There is a special syntax for using routes in markup:

  & lt; Asp: MenuItem NavigateUrl = '& lt;% $ RouteUrl: About root% & gt;' Text = "about" & gt; & Lt; / ASP: MenuItem & gt;    

Comments