0

I'm looking for a way to disable a button before the call of a method and enable when the method has ending.

Code should be something like that:

Btn.Enabled = false;
MyMethode();
Btn.Enabled = true;

But the Btn still be enable.

NB: All the controls are in an UpdatePanel.

I have tried with Js:

ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "document.getElementById('BtnClone').disabled = true; ", true);

ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "document.getElementById('BtnClone').disabled = false; ", true);

The Button stay enable.

Thanks

Nicolas Roche
  • 105
  • 1
  • 1
  • 14

2 Answers2

0

The Solution you can give is you can use the loading gif image once the post back starts, you put the below code in the master page

  <asp:ScriptManager EnablePartialRendering="true" ID="ScriptManagerMain" runat="server"
    AsyncPostBackTimeout="360000">
</asp:ScriptManager>

Before the Content place holder in the master page, put the below update progress

<script type="text/javascript" language="javascript">
            var ModalProgress = '<%= ModalProgress.ClientID %>';         
        </script>
        <script type="text/javascript" src="Scripts/js/jsUpdateProgress.js">
</script>
<asp:Panel ID="panelUpdateProgress" runat="server" CssClass="updateProgress">
            <asp:UpdateProgress ID="UpdateProg1" DisplayAfter="0" runat="server">
                <ProgressTemplate>
                    <div class="divWaiting">
                        <img id="progressImg" src="img/App/Rolling.gif" alt="Processing" height="60px" width="60px" />
                    </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
        </asp:Panel>
        <cc1:ModalPopupExtender ID="ModalProgress" runat="server" TargetControlID="panelUpdateProgress"
            BackgroundCssClass="modalBackground" PopupControlID="panelUpdateProgress" />

The CSS used in the Progress Div as below

.divWaiting
    {
        position: fixed;
        background-color: #313130;
        z-index: 2147483647 !important;
        opacity: 0.8;
        overflow: hidden;
        text-align: center;
        top: 0;
        left: 0;
        height: 100%;
        width: 100%;
        padding-top: 30%;
    }

The jsUpdateProgress.js code as below,

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);

function beginReq(sender, args) {
    // shows the Popup 
    $find(ModalProgress).show();
}

function endReq(sender, args) {
    //  hides the Popup 
    $find(ModalProgress).hide();
}

Try with this , it will open up the loading GIF once the post back starts and it will end when the postback ends up. This will prevent the double click

0

I have solve the problem with this code in the aspx.

<ProgressTemplate>
            <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                <span style="border-width: 0px; position: fixed; padding: 50px; background-color: #FFFFFF; font-size: 36px; left: 40%; top: 40%;">Loading ...</span>
            </div>
        </ProgressTemplate>

It's create a loading message , until the update panel is ready.

Nicolas Roche
  • 105
  • 1
  • 1
  • 14