Tuesday, October 26, 2010

Partial Update in MVC2 (like update panel in classic asp.net)

     
function showAjaxMessage(targetDiv, ajaxMessage) {
var ajaxLoader = "";
$(targetDiv).html("

" + ajaxLoader + " " + ajaxMessage + "

");
}
function submitme() {
submitForm("MyFunction", "#dvdamageAreaMid", "Submitting...", "#BodyWork", function () { alert('Submitted!'); });
}
function submitToPartialView(data) {
getPartialView("UCDamage", "#dvdamageAreaMid", "Loading...", function () { },data );
}

function getPartialView(actionUrl, targetDiv, ajaxMessage, callback,data) {
showAjaxMessage(targetDiv, ajaxMessage);

$.get(actionUrl, { searchText: data }, function (result) {
$(targetDiv).html(result);
callback();
});
}
function submitForm(actionUrl, targetDiv, ajaxMessage, form, callback) {

var data = $(form).serialize();
showAjaxMessage(targetDiv, ajaxMessage);
$.post(
actionUrl,
data,
function (data) {
$(targetDiv).html(data);
callback();
}
);
}

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates