We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Why is ClientSideOnClick not firing?

Hi,

i create a button in code-behind like this:
 Syncfusion.JavaScript.Web.Button b = new Syncfusion.JavaScript.Web.Button();
        b.Text = "Eigene Datei hochladen";
        b.ID = dialog.ID + "bup";
        b.ClientSideOnClick = "alert('Hi');";
        b.ClientIDMode = ClientIDMode.Static;
        b.Type = Syncfusion.JavaScript.ButtonType.Button;
        dialog.DialogContent.Controls.Add(b);

But the ClientSideOnClick (the alert-dialog) never appears.

Yes. I included ej.webforms.min.js

3 Replies

FP Francis Paul Antony Raj Syncfusion Team April 3, 2017 11:11 AM UTC

Hi Carsten, 
 
Thanks for contacting Syncfusion Support. 
 
To utilize the EJ control events, please specify the event handler name (function name) and define this function at client side script section of the sample as mentioned below. 
 
[aspx.cs – code-behind] 
            Syncfusion.JavaScript.Web.Button b = new Syncfusion.JavaScript.Web.Button(); 
            b.Text = "Eigene Datei hochladen"; 
            b.ID = dialog.ID + "bup"; 
            b.ClientSideOnClick = "clientSideClick"; //event handler 'clientSideClick' 
            b.ClientIDMode = ClientIDMode.Static; 
            b.Type = Syncfusion.JavaScript.ButtonType.Button; 
            dialog.DialogContent.Controls.Add(b); 
 
[.aspx] 
<ej:Dialog ID="dialog" runat="server"></ej:Dialog> 
 
[script] 
           function clientSideClick(e) { 
               alert("hi"); 
           } 
 
P:S: EJ Event handler can have function name only and it doesn’t process the string values (like “alert('Hi');”) 
 
Regards, 
Francis Paul A. 



CW Carsten Wuttke April 5, 2017 08:26 AM UTC

Thanks Francis. That worked. Even I then had the problem to give a button-specific data with without creating a script for every single button. But solved it with the WebControls.Button...


FP Francis Paul Antony Raj Syncfusion Team April 6, 2017 07:12 AM UTC

Hi Carsten, 
 
Most Welcome. Please let us know if you need further assistance. 
 
Regards, 
Francis Paul A. 


Loader.
Up arrow icon