How to Pass parameters to Html.ActionLink

I have two input control and and one Html.ActionLink control on my page. How do i pass the value of these input control as parameter to Controller Action.

<input id="txtName" value="MyName" type="Text"/>
<input id="txtAge" value="20" type="Text"/>

<%: Html.ActionLink("Add", "AddName", "EditProfile", new{ --- What to Pass--}, new { @Class = "openDialog", data_dialog_id = "AddCarrierDialog", data_dialog_title = "Add Carrier" })%>

My Controller take two parameter to show detail

[HttpPost]
 public ActionResult AddName(string Name, int Age)
 {
            return PartialView("ShowData");
 }

I am not able to pass txtName and TxtAge values to controller Action. Can Anyone help me out. Thanks in Advance!!!

How to pass parameters to a Flash Lite 1.1 movie?

How can I pass parameters to a Flash Lite 1.1 movie?



How to pass parameters to next page when using ConfigurableNavigationHandler

How can I pass parameters to next page when using ConfigurableNavigationHandler?

How to pass parameters to external webservice from Mule

How can I pass parameters to external webservice via mule flow using CFX?

How to pass anonymous types as parameters?

How can I pass anonymous types as parameters to other functions? Consider this example: var query = from employee in employees select new { Name = employee.Name, Id = employee.Id }; LogEmployees(query

SOLR – How to pass parameters to dataimport

How can i pass additional parameters to SOLR, while importing from database, using dataimport. Example: I have sql query, smth like this: Select * from documents where documentId > [myParameterHer

How to pass anonymous types as parameters?

How can I pass anonymous types as parameters to other functions? Consider this example: var query = from employee in employees select new { Name = employee.Name, Id = employee.Id }; LogEmployees(query

How can I pass parameters to a loaded swf application?

When I load an swf application using SWFLoader in Flex 4, how can I pass parameters to that application?

how to Pass multiple parameters via Command Parameter in WPF?

how to Pass multiple parameters via Command Parameter in WPF?? Do we have to create an object and pass if so can someone help me with an example

How to pass Parameters to json?

I want to pass the below info to Json service. [email protected]&password=mmmmm&apikey=12345&class=User I get the data from json.But how to pass the above parameters to json service. I fa

How can you pass multiple primitive parameters to ASyncTask?

There are related questions, such as How can I pass in 2 parameters to a AsyncTask class? , but I ran into the difficulty of trying in vain to pass multiple primitives as parameters to an AsyncTask, s

Answers

You will need javascript in order to achieve that. A better approach would be to use an html <form> instead of an action link as it will automatically send the values that the user entered in the input fields to the server:

<% using (Html.BeginForm("AddName", "EditProfile", FormMethod.Post, new { @class = "openDialog", data_dialog_id = "AddCarrierDialog", data_dialog_title = "Add Carrier" })) { %>
    <input id="txtName" value="MyName" type="text" />
    <input id="txtAge" value="20" type="text" />
    <input type="submit" value="Add" />
<% } %>