title: ASP.Net code behind wait a ADO.Net query to database returns for redirecting
body: <pre><code>I have a asp.net webform page who uses 2 google charts, I'm using Jquery Ajax to retrieve information from database to populate the charts, the query to retrieve the chart data takes a long time, in this time user can make a click in a link to redirect to another page, the redirect is very slow because wait querys return from database to do the redirect, how can I avoid this behavior?
  
  I'm using Jquery Datatable plugin, when user click one row an javascript event is called
  </code></pre>
  
  <blockquote>
    <p>function redirectToCampaignCreator(campaignID) {
                    try {
                        $.xhrPool.abortAll();
                        redirecting = true;
                        $('#multiCampID').val(campaignID);
                        //window.location.href = "campaigncreator.aspx?Edit=True&amp;CampaignId=" + campaignID;
                        DoPartialPostBack("&lt;%=btnCampaignEdit.UniqueID%>");
                    } catch (e) {
                    }
                }</p>
  </blockquote>
  
  <pre><code>In this function I cancel the Ajax calls and do a __doPostBack(control, ""); to ejecute some code to save session values and then redirect 
  </code></pre>
  
  <blockquote>
  <pre><code>protected void Page_PreInit(object sender, Even`enter code here`tArgs e)
      {
          if (IsPostBack)
          {
              if (Request.Form["multiCampID"] != null)
              {
                  View();
                  Context.Response.Redirect("CampaignCreator.aspx?Edit=True", true);
              }
          }
      }
  </code></pre>
  </blockquote>
  
  <pre><code>The redirect is slow because it's waiting querys return from DB
  </code></pre>