This is a migrated thread and some comments may be shown as answers.
OnClient Event firing on pageload
1 Answer 12 Views
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 30 Jul 2013, 11:33 AM
Hi
I'm having trouble implementing a RadComboBox. The thing I would like to do is to save a temporary state of which checkboxes that where checked when the dropdown list first was opened. The state should then be used to restore the checked checkboxes if the user click on a cancel button.  To do this have I tried the following code.
<telerik:RadComboBox ID="RadComboBox1" Runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" Localization-CheckAllString="Select all"
    EmptyMessage="Select" AutoPostBack="false" LabelCssClass="MultipleChoiceLabels" DropDownCssClass="MultipleChoiceLabels"
    OnClientItemChecked="SaveState('ucMCDFilterByIAI_RadComboBox1')">
</telerik:RadComboBox>

function SaveState(DropDownID) {
    var combo = $find(DropDownID);
    var state = new Array();
    var items = combo.get_items();
    var itemCount = items.get_count();
    for (var counter = 0; counter < itemCount; counter++) {
        var item = items.getItem(counter);
    }
}

The problem I'm experience is that when the page loads, the SaveState method is called. This is not what was intended. Even worse is that $find(DropDownID) is returning null and therefore breaks the whole function. The function is working as it should if I hook up it to a button that is called after the page has loaded. Any suggestions on what whats wrong and what to do?

1 Answer, 1 is accepted

Sort by
0
Marcus
Top achievements
Rank 1
answered on 30 Jul 2013, 12:43 PM
Found the answer to my problem here http://blogs.telerik.com/aspnet-ajax/posts/12-08-10/migrating-onclientclick-handlers-from-asp-button-to-telerik-s-asp-net-ajax-button.aspx. The problem was that I had parentheses in the ClientEvent. Telerik events should not be provided with any parentheses. When I took those away, everything started to work as expected.
Asked by
Marcus
Top achievements
Rank 1
Answers by
Marcus
Top achievements
Rank 1
Share this question
or