Getting the following error randomly on my .aspx that involves javascript and AJAX. It seems to be happening if I don't run the process on the page for 10-15 minutes. After I get one time out it usually works the next try and increasingly gets faster every time after that until it sits idle again.

This page is using a pretty simple stored proc to populate a gridview that is inside an updatepanel.

I get a popup box with the following error:

Sys.WebForms.pageRequestManager TimeoutException : the server request timed out

Code:
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Cust_CM.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>A/R Credit Memos</title>
    <link href="StyleA.css" rel="stylesheet" type="text/css" />

</head>
<body>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Panel ID="Panel2" runat="server" Height="50px" Style="text-align: right" Width="608px">
                        <div style="float: left; width: 200px; height: 100px; text-align: left">
                                                        <br />
                    <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Size="Larger" Text="Credit Memos"
                        Width="192px"></asp:Label><br />
                        </div>
                        <asp:Panel ID="Panel1" runat="server" Height="50px" Width="400px" style="text-align: left">
                            &nbsp;<br />
                            <br />
                            <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                                <ProgressTemplate>
                                    Generating Data...<br />
                                    <img src="pleasewait.gif" />
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </asp:Panel>
                    </asp:Panel>
                    <br />
                    <br />
                        <table style="width: 576px" >
                            <tr>
                                <td style="width: 114px">
                                    <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Invoice Date:" Width="96px"></asp:Label></td>
                                <td style="width: 175px">
                                    <asp:TextBox ID="txtInvoiceDateFrom" runat="server" Width="96px"></asp:TextBox>&nbsp;
                                    <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtInvoiceDateFrom">
                                    </cc1:CalendarExtender>
                                </td>
                                <td style="width: 15px">
                                    <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="To"></asp:Label></td>
                                <td>
                                    &nbsp;<asp:TextBox ID="txtInvoiceDateTo" runat="server" Width="96px"></asp:TextBox>&nbsp;
                                    <cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtInvoiceDateTo">
                                    </cc1:CalendarExtender>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 114px">
                                    <asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Project Number" Width="112px"></asp:Label></td>
                                <td colspan="2">
                                    <asp:TextBox ID="txtProjectNumber" runat="server"></asp:TextBox></td>
                                <td>
                                    <asp:Button ID="btnShow" runat="server" Text="Show Report" OnClick="btnShow_Click" /></td>
                            </tr>
                        </table>
                        <asp:Label ID="lblError" runat="server" ForeColor="Red" Width="576px"></asp:Label><br />
                    <asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="False" EmptyDataText="There were no results to your query.">
                        <Columns>
                            <asp:BoundField DataField="MainProject" HeaderText="Project" />
                            <asp:BoundField DataField="BillTask" HeaderText="Task" />
                            <asp:BoundField DataField="invoice" HeaderText="Invoice No" />
                            <asp:BoundField DataField="InvoiceDate" DataFormatString="{0:d}" HeaderText="Invoice Dt"
                                HtmlEncode="False" />
                            <asp:BoundField DataField="Description" HeaderText="Description" HtmlEncode="False" />
                            <asp:BoundField DataField="footer" HeaderText="Footer" HtmlEncode="False" />
                        </Columns>
                        <RowStyle BackColor="#E0E0E0" />
                        <HeaderStyle BackColor="Silver" />
                    </asp:GridView>
                    &nbsp;&nbsp;

                </ContentTemplate>
            </asp:UpdatePanel>
            
        </div>
    </form>

</body>
    <script type="text/javascript">

        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler)

        function BeginRequestHandler(sender, args)
        {
        var btn = document.getElementById("<%= btnShow.ClientID %>");   
        btn.disabled = true; 
        var txt1 = document.getElementById("<% = txtInvoiceDateFrom.ClientID %>");
        txt1.disabled = true;
        txt1 = document.getElementById("<% = txtInvoiceDateTo.ClientID %>");
        txt1.disabled = true;
        txt1 = document.getElementById("<% = txtProjectNumber.ClientID %>");
        txt1.disabled = true;
        return false;
        }

        function EndRequestHandler(sender, args)
        {
        var btn = document.getElementById("<%= btnShow.ClientID %>");   
        btn.disabled = false; 
        var txt1 = document.getElementById("<% = txtInvoiceDateFrom.ClientID %>");
        txt1.disabled = false;
        txt1 = document.getElementById("<% = txtInvoiceDateTo.ClientID %>");
        txt1.disabled = false;
        txt1 = document.getElementById("<% = txtProjectNumber.ClientID %>");
        txt1.disabled = false;
        return false;
        }

        </script>
</html>
vb Code:
  1. Partial Class _Default
  2.     Inherits System.Web.UI.Page
  3.  
  4.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  5.  
  6.     End Sub
  7.     Private Sub BindGrid()
  8.         Dim cmd As New XSQL("XXXXX", 2)
  9.  
  10.         Try
  11.             cmd.AddStrParam("@Project", txtProjectNumber.Text, 20)
  12.             cmd.AddStrParam("@StDate", txtInvoiceDateFrom.Text, 10)
  13.             cmd.AddStrParam("@EndDate", txtInvoiceDateTo.Text, 10)
  14.             gvResults.DataSource = cmd.ExecuteDS("USP_GetCreditMemos")
  15.             gvResults.DataBind()
  16.             lblError.Text = ""
  17.         Catch ex As Exception
  18.             lblError.Text = ex.Message
  19.         End Try
  20.  
  21.     End Sub
  22.  
  23.     Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  24.  
  25.         If txtProjectNumber.Text = "" Then
  26.             If txtInvoiceDateFrom.Text <> "" And txtInvoiceDateTo.Text <> "" Then
  27.                 BindGrid()
  28.             Else
  29.                 Show("You must enter a Project Number if you are not using a date range.")
  30.             End If
  31.         Else
  32.             BindGrid()
  33.         End If
  34.  
  35.  
  36.     End Sub
  37.     Private Sub Show(ByVal message As String)
  38.         Dim strScript As String
  39.         strScript = "<script type='text/javascript' language='javascript'>"
  40.         strScript = strScript & "alert('" & message & "');"
  41.         strScript = strScript & "</script>"
  42.  
  43.         ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "alert", strScript, False)
  44.  
  45.     End Sub
  46.  
  47.  
  48. End Class