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

2 posts, 0 answers
  1. Naunton
    Naunton avatar
    70 posts
    Member since:
    Jun 2010

    Posted 27 Jun 2011 Link to this post

    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
  2. Naunton
    Naunton avatar
    70 posts
    Member since:
    Jun 2010

    Posted 27 Jun 2011 Link to this post


    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top