Hi. Try'n again. Don't think I stated question clearly.
Got big problem. Company I'm contracting with asked me to convert site to delay loading using AJAX. To do that, I'm using Page methods to load controls. Javascript looks like this... Works like a champ!
$(document).ready(function() {
var clientID = '#' + '<%= BackUpPower.DivBackUpPower.ClientID %>'
if ($(clientID)) {
$.ajax({
type: "POST",
url: "Dashboard.aspx/GetBackUpControl",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
timeout: 15000,
success: function(result) {
$(clientID).css({ "display": "none" });
$(clientID).removeClass('loading');
$(clientID).attr('innerHTML', result.d);
$(clientID).fadeIn("slow");
},
error: function(xhr) {
//alert("GetBackUpControl failed");
}
});
}
});
Server-side code looks like this...
[WebMethod] public static String GetBackUpControl() {
Page page = new Page();
UserControls_BackupPowerForm ctl = (UserControls_BackupPowerForm)page.LoadControl("~/UserControls/BackupPowerForm.ascx");
ctl.ID = "BackupPower";
page.Controls.Add(ctl);
ctl.HostPage = "Dashboard";
ctl.ActiveTimeRange = TimeRange.LastMonth;
try
{
ctl.DataBindChart();
}
catch (Exception caught)
{
LoggingAdapter.LogError(caught.Message, "Error Generating Chart", caught);
return String.Empty;
}
StringWriter writer = new StringWriter();
HttpContext.Current.Server.Execute(page, writer, false);
return writer.ToString();
}
Problem I'm having is when a long running callback is in progress and user tries to switch pages by clicking hyperlink, system waits long time before doing so. Stepping through code I see callback is correcly aborted on new page request and JQuery error handler called, but still seems like new page request is waiting for callback to complete. If no callback is in progress, new page request is instant. Anybody know what is going on?