Mallikarjuna
Mallikarjuna

Reputation: 71

getting the id value of current url in asp.net mvc 2.0

i am using a actionlink in master page of user module.i want to pass the eventid of the current url(in all views) to the actionlink as a route value.But i use the following code,

<%=Html.ActionLink("Create Account", "UserRegistration",
      new { eventid = ViewContext.RouteData.Values["id"] })%>

But it doesnot retrieve the id fom the url.

my url is in following formate,

http://localhost:12905/User/User/Order?eventID=2

here eventID=2 is common for all views.So i want to send this eventID to the actionlink as route value. Thanks in advance,

Upvotes: 0

Views: 146

Answers (1)

M4N
M4N

Reputation: 96596

Shouldn't that be "eventId" instead of "id" in the ActionLink:

<%= Html.ActionLink(... ViewContext.RouteData.Values["eventId"] })%>

Upvotes: 1

Related Questions