2014-07-18 9 views
7

Ciao sto caricando dati enormi da asp.net Ajax sul pulsante clic in visualizzazione griglia che mostra il messaggio di caricamento in aggiornamento prgress ... in aggiornamento tempo di avanzamento devo disabilitare il mio pulsante BtnLoadReport .Disabilita il pulsante per l'avanzamento dell'aggiornamento in ASP.net Ajax

<td> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
</td> 
<td> 
    &nbsp;</td> 
<td> 
&nbsp;</td> 
</tr> 
    <tr> 
    <td> 
    <asp:UpdateProgress ID="updProgress" 
     AssociatedUpdatePanelID="UpdatePanel1" 
     runat="server" oninit="updProgress_Init" onprerender="updProgress_PreRender"> 
      <ProgressTemplate>    
       <span style="color:green; font-style:italic;">Loading, please wait...</span>    
      </ProgressTemplate> 
     </asp:UpdateProgress> 
         <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"> 
         <ContentTemplate> 
         <div id="DemoId"> 
          <asp:Button ID="BtnLoadReport" runat="server" onclick="BtnLoadReport_Click" 
       Text="LoadReport" Width="176px" ClientIDMode="Static" OnClientClick="return clickOnLoadReport();" /> 
       </div> 
          <asp:GridView ID="GridView1" runat="server" Height="170px" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" Width="438px"> 
       </asp:GridView> 
         </ContentTemplate> 
         <Triggers> 
         <asp:AsyncPostBackTrigger ControlID="BtnLoadReport" EventName="Click" /> 
         </Triggers> 
         </asp:UpdatePanel> 
        </td> 
        <td> 
         &nbsp;</td> 
        <td> 
         &nbsp;</td> 
       </tr> 
      </table> 

il mio script per pulsante Disabilita

  <script type="text/javascript"> 
      var updateProgress = null; 
       function clickOnLoadReport() { 
       // This will disable all the children of the div 
       var prm = Sys.WebForms.PageRequestManager.getInstance(); 
       if (prm.get_isInAsyncPostBack()==false) { 
       var nodes = document.getElementById("DemoId").getElementsByTagName('*'); 
       for (var i = 0; i < nodes.length; i++) { 

       nodes[i].disabled = true; 
       // nodes[i].off("click"); 
       } 
      } 
      } 
      </script> 

ma non è invalidante mia tasto per lungo tempo è invalidante per pochi secondi

protected void Page_Load(object sender, EventArgs e) 
     { 
      ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(this.BtnLoadReport); 
     } 

     protected void BtnLoadReport_Click(object sender, EventArgs e) 
     { 
      // System.Threading.Thread.Sleep(3000); 

       UpdatePanel1.Update(); 
       DataSet dataSet = new DataSet(); 
       dataSet.ReadXml(@"C\Data.Xml"); 
       GridView1.DataSource = dataSet.Tables[0]; 
       GridView1.DataBind(); 

     } 

     protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) 
     { 

     } 

     protected void updProgress_Init(object sender, EventArgs e) 
     { 
BtnLoadReport.Enable = false;   
         } 

     protected void updProgress_PreRender(object sender, EventArgs e) 
     { 
      BtnLoadReport.Enable 
= true; 
     } 

questa cosa sopra ho provato a disattivare il mio pulsante BtnLoadReport sul progresso dell'aggiornamento non funziona ancora Grazie in anticipo

risposta

3
function clickOnLoadReport() { 
     var requestManager = Sys.WebForms.PageRequestManager.getInstance(); 
     requestManager.add_initializeRequest(CancelPostbackForSubsequentSubmitClicks); 

     function CancelPostbackForSubsequentSubmitClicks(sender, args) { 
      if (requestManager.get_isInAsyncPostBack() & 
     args.get_postBackElement().id == 'BtnLoadReport') { 
       args.set_cancel(true); 
       document.getElementById("BtnLoadReport").setAttribute("disabled", "disabled"); 
       //alert('A previous request is still in progress that was issued on clicking ' + args.get_postBackElement().id); 
      } 
     } 
    } 

ho apportato modifiche nella mia funzione javascript risolve il mio problema

Problemi correlati