1

I'm very new to .net C# but I wound to get the id I put in the url. In my project details I put a link to create member. but now the users have to select that previous project Id with an combo box. I wound this to be auto.

In my project/details

@Html.ActionLink("Add member", "Create", "ProjectMember", new { id=Model.ProjectID }, null)

Result => ProjectMember/Create/1 (=id from project)

I want to get the ID so wen I create a new projectmember the user does not have to select the id from project from the dropbox that was auto generated in the create view

I looked some things up and came with this answer

<%=Url.RequestContext.RouteData.Values["id"]%>

but when i post this in the It came out the view exactly like <%=Url.RequestContext.RouteData.Values["id"]%>

Keeper01
  • 293
  • 2
  • 4
  • 12
  • please explain properly what you want exactly.. – Kartikeya Khosla Aug 25 '14 at 11:04
  • possible duplicate of [ASP.NET MVC passing an ID in an ActionLink to the controller](http://stackoverflow.com/questions/316889/asp-net-mvc-passing-an-id-in-an-actionlink-to-the-controller) – CodeCaster Aug 25 '14 at 11:12
  • I want to get the ID so wen I create a new projectmember the user does not have to select the id from project – Keeper01 Aug 25 '14 at 12:30

1 Answers1

0

you can pass id in ActionLink Like this

@Html.ActionLink("Add member", "Create", "ProjectMember", new { id=Model.ProjectID }, null)

for more information . see this link ActionLink

Amit Kumar
  • 5,888
  • 11
  • 47
  • 85
  • thank you for getting me the correct syntax but it is not wat I'm looking for – Keeper01 Aug 25 '14 at 12:31
  • @user257696: then what are you looking for . can you explain ? as you explain above, you can get the id in Action Method .you don't need to select from project. – Amit Kumar Aug 25 '14 at 12:38
  • I want to get the ID so wen I create a new projectmember the user does not have to select the id from project from the dropbox that was auto generated in the create view – Keeper01 Aug 25 '14 at 14:38