I am rendering a form in Asp.net MVC with a submit button. The page redirects after successful record addition into the database. Following is the code :-
[HttpP
You can use ajax.BeginForm insted of html.BeginForm to achieve this, if you use OnSuccess
insted of OnBegin
you can be sure that your method execute successful and after that your button turn to deactivate,with ajax you stay
in current view and you can update your current view instead of redirection
@using (Ajax.BeginForm(
new AjaxOptions
{
HttpMethod = "post",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "dive",
OnBegin="deactive"
}))
{
//body of your form same as Html.BeginForm
}
and use this jquery in your form:
be careful for using ajax you have to call this scrip in the end of your page