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

Make CheckBox do both 'OnClick' and fire 'OnCheckedChanged' event

1 Answer 437 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Naunton
Top achievements
Rank 1
Naunton asked on 27 Jun 2011, 10:37 AM
Dear All,

Please help ...
I have a GridTemplateColumn with Checkbox as below
<telerik:GridTemplateColumn UniqueName="Exist" DataField="Exist" HeaderText="Exist">
                <HeaderStyle Width="37px"/>
                <ItemTemplate>
             <asp:CheckBox id="CheckBox1" checked='<%# IF(Eval("Exist") is DBNull.Value, False, Eval("Exist")) %>' OnCheckedChanged="ToggleRowSelection" AutoPostBack="true" runat="server"></asp:CheckBox>
                </ItemTemplate>
</telerik:GridTemplateColumn>
I have added the following code in grid_ItemDataBound event, because of I want to prompt confirm when user click to Checked/UnChecked
chk.Attributes.Add("onclick", "return confirm('Are you sure?')")

Now this only do OnClick, but not fire OnCheckedChanged event.
Any idea to do both when checkedchanged, Please ?

Thanks and best regards

1 Answer, 1 is accepted

Sort by
0
Naunton
Top achievements
Rank 1
answered on 28 Jun 2011, 03:43 AM

Have got the solution by using this
chk.Attributes.Add("onclick", "if(!confirm('Are you sure?')) {return false};")

instead of
chk.Attributes.Add("onclick", "return confirm('Are you sure?')")

Thanks and best regards
Tags
Grid
Asked by
Naunton
Top achievements
Rank 1
Answers by
Naunton
Top achievements
Rank 1
Share this question
or