I have a route definition like this:
routes.MapRoute(
"Pagesize",
"{controller}/{action}/pagesize/{pagesize}",
new { controller = "Home", action = "Index", pagesize = 10 }
);
When I use
<%= Html.ActionLink("MyText", "myaction", new { pagesize = 10 }) %>
it renders as
<a href="/myaction/?pagesize=10">MyText</a>
I can understand I am misusing ActionLink since I have /pagesize/ in between. How can I correctly use it to create the link?
<a href="/myaction/pagesize/10">MyText</a>
Please note that I am using mvc RC2 and no other helper libraries. The generic ActionLink no longer exists in RC2.
From stackoverflow
-
have you tried specifying the defaults in the map route command
routes.MapRoute("Pagesize", "{controller}/{action}/pagesize/{pagesize}", new {pagesize = 10 }, new { controller = "Home", action = "Index" });
Serhat Özgel : I am already setting the defaults with new { controller = "Home", action = "Index", pagesize = 10 }. Also tried your code but did not work. -
Try:
<%= Html.RouteLink("MyText", "Pagesize", new { controller = "Home", action = "Index", pagesize = 10 })%>
Serhat Özgel : Worked perfectly. Thanks.
0 comments:
Post a Comment