I have the following problem, I need to send some data captured in the view to a controller, but I can't find how to do this. I am doing the following.
The data I need to send is 3, user id in session, the event id, and the id of the person to register in the event. At the moment I only know how to send the Id of the user to register, but I don't know how to do it for the others. I do the following.
@Html.ActionLink("AsistenciaEvento", "Create", new { usu = item.numIdUsuario})
I appreciate any suggestion
The extension
ActionLink
as is an overloaded method can cause some problems when determining thelinkText
,actionName
,routeValues
andhtmlAttributes
; in your case it is only necessary:View
Controller
There are other ways to define it, you could review: How to pass the Id of an item from a list and pass it to the controller? , because you need to send multiple parameters your question would not be given as a duplicate.
Update:
As detailed in the comment, when invoking
ActionLink
from the server side it generates an HTML tag<a href=".."></a>
on the client side.For example:
generate:
Therefore, if you need to send form values by url then you have to modify the url of the tag
a
:to solve your problem
In the controller:
In the form I added an element where you will get its value to concatenate to the url of the tag
a
.Using JQuery to manipulate the elements.
P.S. In the end, your problem was really something else, it had nothing to do with the ActionLink