Decorated CheckBoxes have no client-side events

5 posts, 1 answers
  1. Brad
    Brad avatar
    39 posts
    Member since:
    Aug 2010

    Posted 30 Nov 2010 Link to this post

    Is there any way to capture the click event from a decorated checkbox?
  2. Brad
    Brad avatar
    39 posts
    Member since:
    Aug 2010

    Posted 02 Dec 2010 Link to this post

    Is everyone on vacation?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 03 Dec 2010 Link to this post

    Hi Brad,

    The forums are a community resort and we monitor them closely, but we cannot guarantee a timely reply here. If you need a quick reply, I strongly recommend to use the support ticketing system where every ticket has guaranteed reply time corresponding to the license that you have.

    As for the problem itself, could you please provide more details:
    1. The exact version of the controls that you are using
    2. What is your code for handling the click event
    3. Does the problem occur in all browsers or in a specific one.
    I am asking this, because I cannot reproduce the problem locally, so the reason for it might be in some specific setup or condition.

    Best wishes,
    Georgi Tunev
    the Telerik team
    Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
  5. Brad
    Brad avatar
    39 posts
    Member since:
    Aug 2010

    Posted 03 Dec 2010 Link to this post

    UPDATE: I have determined that the markup below has nothing to do with RadFormDecorator: I have commented out all references to them (which is observable) and the control still renders as below.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Telerik UI dll: 2010_3_1109
    I have this problem in FF 3.6.12 and IE 8

    My control (in  a template column in a RadGrid):

    <asp:CheckBox ID="uxIsBillableCheckBox" runat="server" TextAlign="Left" Checked='<%# DataBinder.Eval(Container.DataItem, "IsBillable") %>' Enabled='<%# !(bool)DataBinder.Eval(Container.DataItem, "IsClosed") %>' ToolTip="is the item billable?" onblur="isBillableBlur" onclick="isBillableClick" />

    the JavaScript:

    function isBillableClick(sender) {
        console.log(' *** isBillableClick');
    }
    function isBillableBlur(sender) {
        console.log(' *** isBillableBlur');
    }
     
    how the control renders:

    <span onblur="isBillableBlur" title="is the item billable?"><input type="checkbox" onclick="isBillableClick;" name="ctl00$bodyContentPlaceHolder$uxContainer$uxGrid$ctl00$ctl04$uxIsBillableCheckBox" id="ctl00_bodyContentPlaceHolder_uxContainer_uxGrid_ctl00_ctl04_uxIsBillableCheckBox" _rfddecoratedid="_rfdSkinnedctl00_bodyContentPlaceHolder_uxContainer_uxGrid_ctl00_ctl04_uxIsBillableCheckBox" class="rfdRealInput"><label for="ctl00_bodyContentPlaceHolder_uxContainer_uxGrid_ctl00_ctl04_uxIsBillableCheckBox" unselectable="on" id="_rfdSkinnedctl00_bodyContentPlaceHolder_uxContainer_uxGrid_ctl00_ctl04_uxIsBillableCheckBox" class=" rfdCheckboxUnchecked"> </label></span>

    Notice that there are no client events. The onclick and onblur have disappeared. Also notice, as I just did, that the <input> tag is not closed.



  6. Answer
    Brad
    Brad avatar
    39 posts
    Member since:
    Aug 2010

    Posted 03 Dec 2010 Link to this post

    I have determined that it is not possible to define events on CheckBoxes in template columns in RadGrids (since there is custom rendering happening).

    The solution is something like follows:

    protected void uxGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        Control ctrl;
     
        if (e.Item.ItemType == GridItemType.Item ||
           e.Item.ItemType == GridItemType.AlternatingItem)
        {
            // wire-up client event to myCheckbox checkbox (not possible from apsx)
            ctrl = e.Item.FindControl("myCheckbox");
            if (ctrl != null)
            {
                ((WebControl)ctrl).Attributes["onclick"] = "myCheckboxClickMethod";
            }
        }

    PLEASE MARK THIS AS THE ANSWER
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017