I have html form in which I need to pass data to controller in MVC 4. I need to do it in jquery. The code is:
<% using (Html.BeginForm("CopyEvaluationVersion", "Evaluations"))
<input type="submit" value="Submit" />
The controller
public ActionResult CopyEvaluationVersion(string copyEvaluationVersionId, string copyToYear)
The data is a hidden field
<input type="hidden" id="copyEvaluationVersionId" name="copyEvaluationVersionId" value="<%= ViewData["evaluationVersionId"] %>" />
I need to pass hidden field "copyEvaluationVersionId" to copyEvaluationVersionId controller action ActionResult CopyEvaluationVersion(string copyEvaluationVersionId). I think I need to do it in jquery. But I am not sure how to do it.
copyEvaluationVersionIdis inside the form tags then its value will be posted back when you submit the form. But based on the html your have shown, its value isnull, so what is the point?copyEvaluationVersionIdin your method will be the value of the hidden input (because the input hasname="copyEvaluationVersionId"). Since itsnullin the view (its hasvalue="") it will benullin the controller.