I have a .cshtml page with several buttons like this:
<input id="btnViewHistory" type="submit" name="postFunction" value="View History" />
<input id="btnComments" type="submit" name="postFunction" value="Comments" />
When the form is submitted, the parameter "postFunction" is passed to the controller and I can check what button was pressed:
[HttpPost]
public ActionResult LabApprovals(ModelApproval model, int page, string postFunction)
{
if (postFunction == null)
{
...
}
else if (postFunction == "View History")
{
...
}
else if (postFunction == "Comments")
{
...
}
else
{
return View(model);
}
}
So if you click the "View History" button, when the controller is hit postFunction="View History".
I need to submit the form from Javascript for another reason other than a button press. I have the Javascript to submit the form, but how do I pass a parameter?I'm trying to get postFunction to have a value such as "Changed Page" when the controller is reached.
$("#txtPage").kendoNumericTextBox({
change: function () {
$("#formLabApprovals").submit();
}
});