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
265
Web Image Button - Java Script
posted

How can I run Java Script from the Web Image Button?

  • 24497
    posted

    Hi,

    If you ask how to run script on button click, then WebImageButton supports 2 options.

    1. Set explicit script statements
    2. Set name of function which will be called on click

    You also probably will want to disable default autopostback.

    Below examples for 2 cases:

    <script type="text/javascript">
    function
    WebImageButton2_Click(oButton, oEvent)
    {
      alert(
    'WebImageButton2_Click');
    }
    </script>

    <igtxt:WebImageButton ID="WebImageButton2" runat="server" AutoSubmit="False">
     
    <ClientSideEvents Click="WebImageButton2_Click" />
    </igtxt:WebImageButton>

    <igtxt:WebImageButton ID="WebImageButton1" runat="server">
     
    <ClientSideEvents Click="alert('click')" />
    </igtxt:WebImageButton>