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

Decorated CheckBoxes have no client-side events

4 Answers 82 Views
FormDecorator
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 30 Nov 2010, 08:43 PM
Is there any way to capture the click event from a decorated checkbox?

4 Answers, 1 is accepted

Sort by
0
Brad
Top achievements
Rank 1
answered on 02 Dec 2010, 09:39 PM
Is everyone on vacation?
0
Georgi Tunev
Telerik team
answered on 03 Dec 2010, 10:45 AM
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.
0
Brad
Top achievements
Rank 1
answered on 03 Dec 2010, 03:31 PM
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.



0
Accepted
Brad
Top achievements
Rank 1
answered on 03 Dec 2010, 05:24 PM
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
Tags
FormDecorator
Asked by
Brad
Top achievements
Rank 1
Answers by
Brad
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or