Disabled button doesn't submit postback in UpdatePanel

前端 未结 2 1179
小鲜肉
小鲜肉 2020-12-22 07:36

I have a button inside UpdatePanel on my ASP.NET Page. Here\'s my UpdatePanel



        
相关标签:
2条回答
  • 2020-12-22 07:44

    Add ClientIDMode="Static"on the button

    <asp:Button ID="btnPrint" runat="server" OnClick="btnPrint_Click" ToolTip="Click to export report to PDF" Width="100px" Text="Print to PDF" OnClientClick="if(PDFClick()) {return true;} else {alert('2');}" ClientIDMode="Static" />
    
    0 讨论(0)
  • 2020-12-22 07:51

    You can disable the button asynchronously with setTimeout:

    <script type="text/javascript">
        function PDFClick(btnPrint) {
            btnPrint.value = "Working...";
            setTimeout(function() { btnPrint.disabled = true; }, 10);
            return true;
        };
    </script>
    

    The call to document.getElementById can be removed from PDFClick by passing a reference to the button element with the this keyword in OnClientClick:

    OnClientClick="if (PDFClick(this)) { return true; } else { alert('2'); }"
    
    0 讨论(0)
提交回复
热议问题