In my form I have a textbox as below
@Html.TextBox("first_name")
I need to pass the value of this textbox to controller through a actionlink.
I tried the below
@Html.ActionLink("View", "view_Details", new { name = first_name})
but this is giving error
"first_name" does not exist in the current context
Is this possible using a Actionlink?
My controller signature is
public ActionResult view_Details(string name)
{
return View();
}
Edited
@Html.ActionLink("View", "view_Details", new { name = getname()})
<script type="text/javascript">
function getname() {
return $("#first_name").val();
}
</script>
I tried above code. Its also giving error
getname() does not exist in the current context
getname()is a client side method which does not exist at that point. I'll post a answer shortly showing how you can do this.