I am working on a simple CMS project, and i have run into a wall. And then after a lot of hours, blew it up.
For some reason my buttons inside @Ajax.BeginForm were not activating the postback. Neither full postback nor ajax. I have referenced the scripts, and tried to debug jQery, examined every character in the Controllers, Views, References and Models to no avail. There were no errors or exceptions thrown.
Controller action:
[HttpPost]
public ActionResult Delete(int ID,int page=1)
{
//some code...
//...work, work, work...
}
View segment:
@using (Ajax.BeginForm("Delete", "Client", new { page = Model.CurrentPageIndex }, ao))
{
@Html.Hidden("clientID", item.ClientID)
<input type="submit" value="Briši" name="brisi" />
}
Error:
The parameters dictionary contains a null entry for parameter 'ID' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Delete(Int32, Int32)' in 'Info3CRM.WebUI.Controllers.ClientController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
Finally i have decided to disable jQuery and Ajax and do normal postback. Then the exception was thrown. I was trying to call the Action in controller without all the necessary parameters.
My question to all is: How to catch such an exception if jQuery and ajax are enabled?