I have an asp.net page where the page will query the report from the database. To query the report itself might cause timeout exception on the page itself before the report result is being returned from database.
You need to do it in two steps, first you need to override the script timeout only for the pageitself. put this code in your code behind
Dim pageTimeOut As Integer
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
pageTimeOut = Server.ScriptTimeout
'this is in seconds
Server.ScriptTimeout = 2500
End Sub
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
Server.ScriptTimeout = pageTimeOut
End Sub
The next step is required only if you use AJAX Update panel. Put this script on the aspx page
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
function (sender, args)
{
if (args.get_error() && args.get_error().name == 'Sys.WebForms.PageRequestManagerTimeoutException')
{
// remember to set errorHandled = true to keep from getting a popup from the AJAX library itself
args.set_errorHandled(true);
}
});
Last few months, I got a problem to place a button to generate a CSV file in the update panel. I was having a problem related with response error. So what i did was to place the button outside the Update Panel. Today, I found a simple solution to place this button inside the AJAX Update panel
1. You need to set the page mode on the page load event
protected void Page_Load(object sender, EventArgs e)
{
this.Page.Form.Enctype = "multipart/form-data";
}
2. set the update Panel Children as trigger to true
3. set the trigger to your button
I believe this will be useful for everyone who wants to implement AJAX manually and make it compatible cross browser.
// cross-browser method to retrieve an XMLHttp object for asynchronous requests & responses
function GetHTTPRequest()
{
var http_request = false;
if (window.XMLHttpRequest)
{
// Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType("text/xml");
}
}
else if (window.ActiveXObject)
{
// IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
return http_request;
}
I tried to implement AJAX on my website by using AJAX extension on visual studio .NET. I tried to drag update panel to my page and I’ve put my button event handler to the trigger collection in update panel. I was expecting when i click that particular button then it will not refresh or load up the page, but in fact it reloads the page which showing me that the AJAX panel does not work, and my firebug detects that there are errors related with sys is undefined.
This happens because I haven’t AJAX config on my web.config. The config is related with HTTP handler, you can try to put this in your web.config. Please make sure it should be inside “”
I’ve got this error when i have ajax toolkit script manager on the master page while at the same time i’ve script manager on the content page. This is the primary cause of this error.
The work around this is to move the script manager which is located on the master page before the content place holder or if you have any user control which uses script manager as well, place before it. It should be placed on the top of anything which uses this control and the most important thing you need to change the script manager in the content page or user control to be script manager proxy