Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
Disable Image Button
posted

I have dialog box with a Imagebutton (which is used as a save) and l want to stop users pressing it more than once.

Hiw can l disable the button and still call the server side event?

 

  • 24497
    posted

    Hi Naish,

    If button is disabled, then you may use __doPostBack. Below is example:

    <script type="text/javascript">
    function WebImageButton1_Click(oButton, oEvent)
    {
     // if that is external event (not from WebImageButton.ClientSideEvents),
     // then to get reference to WebImageButton1 you may use:
     //var oButton = ig$('<%=WebImageButton1.ClientID%>');
     oButton.setEnabled(false);
    }
    function triggerClick()
    {
     var oButton = ig$('<%=WebImageButton1.ClientID%>');
     if(oButton.getEnabled())
      oButton.click();
     else
      __doPostBack(oButton.getUniqueID(), '0');
    }
    </script>
    <igtxt:WebImageButton ID="WebImageButton1" runat="server" Text="Once">
       <ClientSideEvents Click="WebImageButton1_Click" />
    </igtxt:WebImageButton>
    <input type="button" value="Trigger Click Event" onclick="triggerClick()" />