Asp.net Postback issue
I have Department Dropdown on change of this I made jquery-ajax request to get the Department Details.
I'll be binding this result to a Div.
that works well till here.
W开发者_高级运维hen I click an asp.net button or any server side control after post back the div element is emptied.
How can I get the previous result in the div element.
Success function for Ajax call goes like below:
function OnSuccess(response) {
var List = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
DeptDetails = "";
$.each(List, function () {
DeptDetails = "<table cellpadding='0' cellspacing='0' class='grid' border='0' width='94%'>";
DeptDetails = DeptDetails + "<tr><td align='right' style='padding-left: 10px; padding-top: 3px;'>Store Name:</td><td align='left' style='padding-left:3px;padding-top:3px;'>" + this["DeptName"] + "</td></tr>";
DeptDetails = DeptDetails + "<tr><td align='right' style='padding-left: 10px; padding-top: 3px;'>Address:</td><td align='left' style='padding-left:3px;padding-top:3px;'>" + this["Address"] + "</td></tr>";
DeptDetails = DeptDetails + "<tr><td align='right' style='padding-left: 10px; padding-top: 3px;'>Zone:</td><td align='left' style='padding-left:3px;padding-top:3px;'>" + this["ZoneName"] + "</td></tr>";
DeptDetails = DeptDetails + "<tr><td align='right' style='padding-left: 10px; padding-top: 3px;'>Zone Manager:</td><td align='left' style='padding-left:3px;padding-top:3px;'>" + this["ZoneManager"] + "</td></tr></table>";
$('div[id*="divDeptDetails"]').html(DeptDetails);
});
}
Thanks in advance.It is urgent guys.
jQuery(document).ready(function(){
// check here if the drop down has a selected item different than the default one
// make the same ajax call you are doing on the drop down
})
Anand, you need to persist the data by adding the data to the viewstate or by sending it along with a hidden input.
精彩评论