This is a migrated thread and some comments may be shown as answers.

OnClientClick event not work in grid itemtemplete

3 Answers 190 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 11 Feb 2014, 11:10 AM
Hi, I want to call client side function than server side using OnClientClick Functionl on link button inside grid item template but it not work well so provide working examples.

client side function :

 function chkpermissionsEdit() {        
          var add =1;
          if (add == 0) { bootbox.alert("You have no permissions to Update Record"); return false; }
          else { return true; }
      }

  <telerik:GridTemplateColumn AllowFiltering="false" UniqueName="Action" HeaderText="Action" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                                                                        <ItemTemplate>
                                                                            <telerik:RadButton ButtonType="LinkButton" runat="server" ID="btnEdit" 
                                                                                ToolTip="EditRecord"  Text="Edit" CommandName="EditButton" 
                                                                                CommandArgument='<%# Eval("LandlordId") %>' onClientClicked="return chkpermissionsEdit();"   />
                                                                         
                                                                        </ItemTemplate>
                                                                        <HeaderStyle HorizontalAlign="Left" />
                                                                        <ItemStyle HorizontalAlign="Left" />
                                                                    </telerik:GridTemplateColumn>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Feb 2014, 11:21 AM
Hi Rahul,

Please try the following code snippet to have an OnClientClicked event for the RadButton:

ASPX:
<telerik:RadButton runat="server" ID="btnEdit" OnClientClicked="chkpermissionsEdit" . . . />

JS:
function chkpermissionsEdit() {
    //Your Code
  }

Thanks,
Princy
0
Rahul
Top achievements
Rank 1
answered on 11 Feb 2014, 01:21 PM
Thanks for replay,

the function returns true or false if  it return true than call server side else it return false not execute server side code.
it always return true. so provide solutions.

Thanks
Rahul
0
Princy
Top achievements
Rank 2
answered on 12 Feb 2014, 04:00 AM
Hi Rahul,

I'm not clear about your requirement. From your code the function always returns true because according what you have set add is always 1 and the if condition is never entered. Please make sure you have add=0 for that condition to be fired. Please elaborate on your requirement to help you more.

Thanks,
Princy
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rahul
Top achievements
Rank 1
Share this question
or