Posting the same form for different actions depending on the click of a button

I have a similar article about this on StackOverflow, but maybe my misunderstanding is more significant. I have an Index () action, and the index is viewing its rendering. From the Index () view, depending on the pressed button, [HttpPost] Index () or [HttpPost] Search () needs to be called, because I am sending some data. The only way to post different actions is to use jQuery? If jQuery is the only way if my actions return views (full HTML pages), do I need to clear the entire document element from $ .post and fill it with my html views? I'm new to this, thanks a ton!

@using (Html.BeginForm())
{
    <input name="startDate" type="text" size="20" class="inputfield" id="datepicker" />
    <a href="#" id="apply_button">...</a>
    <a href="#" id="go_button">...</a>
}


public ActionResult Index(string lang)
{
    return View();
}

//Perhaps this action is needed
[HttpPost]
public ActionResult Index(string lang, string startDate)
{
    return View();
}

[HttpPost]
public ActionResult Search(string lang, string startDate)
{
    return View();
]
+5
2

, .

. "", "go":

$('#go_button').click(function() {
    $('form').attr("action", "Search");  //change the form action
    $('form').submit();  // submit the form
});
+14

, , :

$('#go_button').click(function() {
    $('form').attr("action", "@("Search","OtherControllerName")");  //change the form action
    $('form').submit();  // submit the form
});
0

All Articles