asp.net - how do you set a url routing routevalue to a hyperlink's navigate url property in an aspx page? -
if following routes:
routes.mappageroute( "build", // route name "build", // route url "~/build.aspx" // web page handle route ); routes.mappageroute( "type", // route name "build/{type}", // route url "~/build.aspx" // web page handle route ); routes.mappageroute( "project", // route name "build/{type}/{project}", // route url "~/build.aspx" // web page handle route ); routes.mappageroute( "task", // route name "task/{type}/{project}", // route url "~/task.aspx" // web page handle route );
how set hyperlinks navigate url in .aspx (not code behind) route named 'task' type = 'tool' , project = 'excel'?
for example, in grid view template field:
<asp:templatefield> <itemtemplate> <asp:hyperlink runat="server" id="btnup" text='<%# eval("projectid") %>' navigateurl='<%# getrouteurl("task", new system.web.routing.routevaluedictionary { {"type", "tool" }, {"project" , "excel" } }) %>' /> </itemtemplate> </asp:templatefield>
or, can set parameters data source:
<asp:templatefield> <itemtemplate> <asp:hyperlink runat="server" id="btnup" text='<%# eval("projectid") %>' navigateurl='<%# getrouteurl("task", new system.web.routing.routevaluedictionary { {"type", eval("type") }, {"project" , eval("projecttype") } }) %>' /> </itemtemplate> </asp:templatefield>
Comments
Post a Comment