I have two text inputs, content of which needs to be passed to a certain action as parameters when a button is clicked. I’m using MVC3
View:
<input name="input2" type="text" class="inputfield" id="datepicker_1" /></td>
<input name="input2" type="text" class="inputfield" id="datepicker_2" /></td>
@Html.Action("Search", ...)
Controller:
public ActionResult Search(…)
I suppose the object routeValues or RouteValueDictionary should be used in the @Html.Action for this. These object are confusing for me a bit. Could anyone clarify this for me please. Thank you!
The Html.Action will probably generate the link html before you provide the inputs. You need to either place your inputs inside a form to be submited to your action, or use ajax, with jquery perhaps, to call the action, like so:
For an Ajax example, check this question:
jquery ajax forms for ASP.NET MVC 3
Hope this helps…