Ajax.BeginForm Force Full Postback
How do I force Ajax.BeginForm (MVC3, unobtrusive) to do a full postback? In MVC2 I just cleared the 'onclick' and 'onsubmit' handlers. How do I do this in MVC3? //does not work in
Solution 1:
If you are fine with modifying the unobtrusive library.. you can check in the submit event handler whether the form contains any file and if yes then do a full POST else through AJAX.
$("form[data-ajax=true]").live("submit", function (evt) {
var clickInfo = $(this).data(data_click) || [];
evt.preventDefault();
if (!validate(this)) {
return;
}
if ($("input[type=file]", this).val()) {
this.submit();
}
else {
asyncRequest(this, {
url: this.action,
type: this.method || "GET",
data: clickInfo.concat($(this).serializeArray())
});
}
});
Post a Comment for "Ajax.BeginForm Force Full Postback"