i need help with ASP MVC.
I have:
<% using (Html.BeginForm(null,null,FormMethod.Post)) {%>
<p>
<input type="submit" value="Choose" />
.
.
.
<%=Html.ActionLink("Save", "Index")%>
</p>
<% } %>
And i need to submit the form by that ActionLink, because i need to get selectedValue from dropdownlist and i do not know any way how to do that else then from FormCollection or parameter in method with attribute POST.
So i need to call this function after click on action link.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection formValues)
{
}
I tried something with jquery and Ajax.ActionLink but everything called the GET method of Index. (new { onclick = "$(this).parents('form').first().submit();" – did not work for me -it also called the GET method)
You need to call the form’s submit and then return false. Javascript:
That should submit the form without sending you to the GET URL.