OnclientClosing does not fire in Radcombobox control

2 posts, 0 answers
  1. Prathap
    Prathap avatar
    10 posts
    Member since:
    Oct 2008

    Posted 08 May 2012 Link to this post

    I am using radcombobox with checkbox options.
    I need onclientclosing event to be fired for a web part.
    I was able to achieve this using aspx page as shown below

    <telerik:RadComboBox ID="cmbSites" CheckBoxes="true" EnableCheckAllItemsCheckBox="true"  runat="server" HighlightTemplatedItems="true" MaxHeight="200" EmptyMessage="+ Select Site +"
                            width="300px" Skin="MySkin_Default" EnableEmbeddedSkins="false" OnClientDropDownClosing="HandleCloseSite" />
    java script
    function HandleClose(combo) {
              var items = combo.get_items();
              var csv = "";
              for (i = 0; i < items.get_count(); i++) {
                  var chk = getItemCheckBox(items.getItem(i));
                  if (chk != null && chk.checked) csv += "," + items.getItem(i).get_value();
              if (csv.length > 2) {
                  return csv.substring(1);
                  return combo.get_value();
    Now I need write the same code in code behind for a web part.
    in createchildcontrols I am declaring the radcombobox
                cmbChildEntities = new RadComboBox();
                cmbChildEntities.Visible = true;
                cmbChildEntities.AutoPostBack = true;
                cmbChildEntities.EnableCheckAllItemsCheckBox = true;
                cmbChildEntities.HighlightTemplatedItems = true;
                cmbChildEntities.CheckBoxes = true;
                cmbChildEntities.Width = 275;
                cmbChildEntities.EnableEmbeddedSkins = false;
                cmbChildEntities.Skin = "MySkin_Default";
    In render I have a javascript call
     string js;
                    js = "function HandleCloseRegion(){\n";
                    js += "alert('test.');\n";
                    js += "}\n";

                    Page.ClientScript.RegisterStartupScript(this.GetType(), "PIROptions", js, true);
  2. Ivana
    Ivana avatar
    657 posts

    Posted 11 May 2012 Link to this post

    Hi Prathap,

    Here is how you could create RadComboBox dynamically and register its client event handlers on the page as well:
    protected void Page_PreInit(object sender, EventArgs e)
        RadComboBox combo = new RadComboBox();
        combo.ID = "RadComboBox1";
        combo.CheckBoxes = true;
        combo.EnableCheckAllItemsCheckBox = true;
        combo.AutoPostBack = false;
        combo.HighlightTemplatedItems = true;
        combo.Items.Add(new RadComboBoxItem("111", "111"));
        combo.Items.Add(new RadComboBoxItem("222", "222"));
        combo.Items.Add(new RadComboBoxItem("333", "333"));
        combo.Items.Add(new RadComboBoxItem("444", "444"));
        combo.Items.Add(new RadComboBoxItem("555", "555"));
        combo.OnClientDropDownClosing = "HandleCloseRegion";
        string hanldeCloseRegion = @"function HandleCloseRegion(sender, args){
              var csv = '';
              sender.get_checkedItems().forEach(function(item, index){
                csv += ',' + item.get_value()
              if (csv.length > 2) {
        ScriptManager.RegisterClientScriptBlock(this, GetType(), "handler", hanldeCloseRegion, true);

    I hope this will help.

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top