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

OnClick

I'm using ej button. I'm trying to use OnClick event to fill some data on diialog.
Click Event is not working.

Code:

 <asp:UpdatePanel ID="pnlLeft" runat ="server" >                               
                <ContentTemplate>           
                  <div style="width:100%;vertical-align:top;">     
                       
                              <div style ="margin-left:20px;margin-right:20px;">
                                     <GraweControls:graweGrid id ="gvMaterijali" runat="server" />   
                                  <ej:Button ID="btnNovo" Type ="Button"  runat="server" Text = "UNOS" OnClick ="btnNovo_Click" ClientSideOnClick ="openDialog" />&nbsp;&nbsp;&nbsp;
                                  <ej:Button ID="btnPromjena" runat ="server" Text ="PROMJENI" OnClick ="btnPromjena_Click" ClientSideOnClick ="openDialog"  />&nbsp;&nbsp;&nbsp; 
                                  <ej:Button ID="btnBrisi" runat="server" Text ="OBRIŠI"  OnClick ="btnBrisi_Click" />&nbsp;&nbsp;&nbsp;                                   
                              </div>
                   </div>
                </ContentTemplate>
                         <Triggers>
                             <asp:AsyncPostBackTrigger ControlID="gvMaterijali" />                               
                         </Triggers>          
             </asp:UpdatePanel>    


code Inside:

 Protected Sub btnNovo_Click(ByVal sender As Object, ByVal e As Syncfusion.JavaScript.Web.ButtonEventArgs)

        dialogMaterijal.ShowOnInit = True
        NapuniFilterGrupeMaterijala()
        ocistiPolja()

        btnSave.Text = "SPREMI"

    End Sub


9 Replies

DL Deepa Loganathan Syncfusion Team November 23, 2016 07:36 AM UTC

Hi Hrvoje,  
Thanks for contacting Syncfusion Support.  

Usually, the Server side event might not be triggered due to one of the following reasons. So, please check if,
1. ASP script manager is referred in your layout page.
2. ej.webform.min.js file is referred at the end of the script section as given below. 
 
 
<%: Scripts.Render("~/Scripts/jquery-1.10.2.min.js")%> 
<%: Scripts.Render("~/Scripts/jsrender.min.js")%> 
<%: Scripts.Render("~/Scripts/ej/ej.web.all.min.js")%> 
<%: Scripts.Render("~/Scripts/ej/ej.webform.min.js")%> 
 

We have explained the necessity to refer the above mentioned references in our help documents under Adding required Script files section.
https://help.syncfusion.com/aspnet/getting-started#configuring-syncfusion-npm-packages  
 
Please let us know if you need any further assistance. 

Regards, 
Deepa Loganathan.  



HV Hrvoje Voda November 23, 2016 07:57 AM UTC

Buttons now work, but page is refreshing every time I click on button, and selected row on grid doesn't stay selected.
I put Dialog alsno in update panel

Here is a dialog:

 <asp:UpdatePanel ID="UpdatePanel1" runat ="server" >                               
                <ContentTemplate>   
                      <div id="dlg" style="visibility:hidden">
                      
                            <ej:Dialog ID="dialogMaterijal" Title="UNOS / PROMJENA MATERIJALA" ShowOnInit="false" runat="server" Width="750">
                                <DialogContent>                                                                                         
                                    <div style ="float:left;width:65%; height:700px;">    
                                         ID materijala<br />               
                                        <asp:Label ID="lblID" runat="server" /><br /><br />
                                        Grupa materijala<br />
                                        <asp:DropDownList ID="ddlGrupaMaterijala" runat="server"></asp:DropDownList><br /><br />
                                        Materijal<br />
                                        <asp:TextBox ID="txtMaterijal" runat="server" Width="550px"></asp:TextBox><br /><br />
                                        Serijski broj<br />
                                        <asp:TextBox ID="txtSB" runat="server"></asp:TextBox><br /><br />
                                        Jedinična cijena<br />
                                        <asp:TextBox ID="txtCijena" runat="server" Width="70px"></asp:TextBox><br /><br />
                                        Popust<br />
                                        <asp:TextBox ID="txtPopust" runat="server" Width="80px"></asp:TextBox><br /><br />
                                        Stanje zaliha<br />
                                        <asp:TextBox ID="txtZalihe" runat="server" Width="80px"></asp:TextBox><br /><br />
                                        Opis<br />
                                        <asp:TextBox ID="txtOpis" runat="server" Rows ="5" Width ="447px" TextMode="MultiLine"></asp:TextBox><br /><br />     
                                      <ej:Button ID="btnSave" runat="server" CssClass ="button" OnClick = "Save" />                                        
                                 </div>   
                                   <div style ="float:right;width:35%; height:300px;" runat ="server" >
                                        <asp:Image ID="imgMat" runat="server" Height="200" Width="150" CssClass ="imgFilter" />&nbsp;
                                       <asp:FileUpload ID="FileUpload1" runat="server" />
                                   <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick = "UploadedComplete" />                                                                          
                                    
                                  </div>                           
                                </DialogContent>
                            </ej:Dialog>                                     
                      </div>              
             </ContentTemplate>
                        <Triggers>
                                <asp:AsyncPostBackTrigger ControlID = "dialogMaterijal" />
                        </Triggers>
            </asp:UpdatePanel>    


DL Deepa Loganathan Syncfusion Team November 24, 2016 10:56 AM UTC

Hi Hrvoje,  
Sorry for the inconvenience 
Query #1: Page is refreshing every time I click on button 
From the given code, we see that you have bound a server side event to the button control. Whenever a server side event is bound to any control, a postback event will be fired and the data will be sent to the server. This causes the page to reload upon button click. However, you could differentiate between postback and page refresh event using Page.IsPostBack property as given below. 
If (Page.IsPostBack) Then 
 
End If 
 
Query #2: Grid selection is not persisted upon Postback 
We are unable to reproduce the problem at our end. We have prepared a sample with the given code example and already discussed scenarios that can be downloaded from the following location.  
We have an API named EnableViewState which decides whether to save the view state or not. If you have disabled this property, it will never save the view state while performing the PostBack trigger. So we suggest to ensure whether this property has been disabled or enabled in your Grid.  
            <ej:Grid ID="OrdersGrid" runat="server" EnableViewState="false" AllowPaging="true">  
             . . .   
            </ej:Grid>  
  
If you are still facing any problem, please share the following details to analyze the problem and provide you solution as early as possible.  
1)      Code example of Grid and Code behind  
2)      Version of the Essential Studio  
3)      Stack trace of browser console (if any error)  
4)      If possible modify the attached sample and replicate the issue   
Regards,  
Deepa Loganathan. 



HV Hrvoje Voda November 24, 2016 11:46 AM UTC

 can't run your code ...some dll are missing...
But , I put everything in code like yours and it still not working.

Code behind:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            grupaMaterijalaLoad(conn)
        End If

        materijaliLoad(conn) -> this fill grid with data

      AddHandler gvMaterijali.grdSelectedRow, AddressOf GridView_SelectedRow

End Sub

 Protected Sub GridView_SelectedRow()

        For Each keyval As KeyValuePair(Of String, Object) In gvMaterijali.data

            Select Case keyval.Key
                Case "ID"
                    Session("ID") = Convert.ToInt32(keyval.Value).ToString()
                Case "Grupa materijala"
                    Session("Grupa materijala") = keyval.Value
                Case "Materijal"
                    Session("Materijal") = keyval.Value
                Case "Opis"
                    Session("Opis") = keyval.Value
                Case "Popust"
                    Session("Popust") = keyval.Value
                Case "Cijena"
                    Session("Cijena") = keyval.Value
                Case "Stanje zaliha"
                    Session("Stanje zaliha") = keyval.Value
                Case "ImageID"
                    If keyval.Value = 9999 Then
                        Session("img") = "~/_COMMON/Images/noimage.png"
                    Else
                        Session("img") = "~/_COMMON/Images/UMA/" + keyval.Value.ToString() + ".jpg"
                    End If
            End Select
        Next
    End Sub

 Protected Sub btnNovo_Click(ByVal sender As Object, ByVal e As Syncfusion.JavaScript.Web.ButtonEventArgs)

        dialogMaterijal.ShowOnInit = True
        NapuniFilterGrupeMaterijala()
        
        btnSave.Text = "SPREMI"

    End Sub

2) I'm using Esential Studio 14.3.0.49
3)  I get no error


JK Jayaprakash Kamaraj Syncfusion Team November 25, 2016 12:07 PM UTC

Hi Hrvoje, 
 
We have created a grid sample in 14.3.0.49V. But, we were unable to reproduce the issue at our end. Please refer to the below sample 
 

Please share the following information to find the cause of the issue.    
 
1.     Grid Rendering code example (both view and code behind ) 
2.     Share the video/screenshot to show the issue 
3.     If possible, provide an issue reproducing sample or replicate the issue in the attached sample.   
 
Regards, 
 
Jayaprakash K. 



HV Hrvoje Voda November 25, 2016 12:51 PM UTC

I send you all my code in previous reply.
I don't know what else to do. I tried everything.

Click event not working and now, as new, button for edit refreshes page. It's all a mistery to me...




FS Farveen Sulthana Thameeztheen Basha Syncfusion Team November 28, 2016 12:20 PM UTC

Hi Hrvoje,   
   
  
Query #1: Click event not triggered   
  
   
Could you please ensure in your sample whether “EnabledViewState” property has been enabled or not? Because when you have disabled this property, it will never save the view state and the “serverside events” such as OnServerRecordClick event will not be triggered.    
  
We have created a sample as like in 14.3.0.49 version. But, we are unable to reproduce the issue “click event not working” at our end. Please refer to the sample.   
   
   
   
   
   
Also, we have attached the video about triggering of click event. Please download it from the below location.   
   
   
   
  
   
So please share us the following details so that we could sort out the cause of the issue and provide a solution as early as possible.  
   
   
1. Grid rendering code example like the following code in your sample (both master and View page code example)   
   
<ej:Button ID="btnNovo" Type="Button" runat="server" Text="UNOS" OnClick="btnNovo_Click"ClientSideOnClick="openDialog" />   
   
<ej:Grid ID="OrdersGrid" runat="server" EnableViewState="true" DataSourceID="OrderData"AllowPaging="true">   
           
 <ToolbarSettings ShowToolbar="True"  ToolbarItems="add,edit,delete,update,cancel,save"/>   
         
 <EditSettings AllowAdding="True" AllowDeleting="True" AllowEditing="True" />   
       <Columns>   
           <ej:Column Field="OrderID" IsPrimaryKey="true" HeaderText="Order ID"/>   
           <ej:Column Field="CustomerID" HeaderText="Customer ID"/>   
       </Columns>   
  </ej:Grid>   
   
   
   
2. Share the video/screenshot to show the issue.   
3. If possible, replicate the issue in the above attached sample and revert us.   
   
   
Query #2: Usage of Button   
   
   
You have also mentioned about the button for edit refreshes page. Please share the following details.   
   
   
1. Explain the functionality of the button and also share the code whether the button has been used inside the Grid control or else at the external button click?   
   
2. Share the code example of button click event and the operations performed using that event.   
   
   
Regards,   
   
Farveen T.   
 



HV Hrvoje Voda November 28, 2016 12:51 PM UTC

Buttons are below grid inside div element:

 <asp:UpdatePanel ID="pnlLeft" runat ="server">                               
                <ContentTemplate>           
                  <div style="width:100%;vertical-align:top;">
                              <div style ="margin-left:20px;margin-right:20px;">
                                     <GraweControls:graweGrid id ="gvMaterijali" runat="server" EnableViewState="True" />   
                                  <ej:Button ID="btnNovo" Type ="Button" runat="server" CssClass ="button" Text = "UNOS" OnClick ="btnNovo_Click" ClientSideOnClick= "openDialog" />&nbsp;&nbsp;&nbsp;
                                  <ej:Button ID="btnPromjena"  runat ="server" Text ="PROMJENI" CssClass ="button" OnClick ="btnPromjena_Click" ClientSideOnClick ="openDialog"  Type="Button" />&nbsp;&nbsp;&nbsp; 
                                  <ej:Button ID="btnBrisi" runat="server" Text ="OBRIŠI" CssClass ="button"  OnClick ="btnBrisi_Click" />&nbsp;&nbsp;&nbsp;                                   
                              </div>
                   </div>
            </ContentTemplate>
              <Triggers>
                  <asp:AsyncPostBackTrigger ControlID = "gvMaterijali" />                  
              </Triggers>
          </asp:UpdatePanel>


I also tried to put it all in one updatePanel but it still not working.
Maybe the problem is grid as user control..


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team November 29, 2016 11:53 AM UTC

Hi Hrvoje, 
 
We have created a new support incident under your account. Please log on to our support website to check for further updates. 
 
 
Regards, 
Seeni Sakthi Kumar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon