An usercontrol with Radcombobox and RadWindo

2 posts, 0 answers
  1. Kalyani
    Kalyani avatar
    20 posts
    Member since:
    Jul 2011

    Posted 07 Oct 2014 Link to this post

    Hello,

    I am hoping someone can help me with my code.  I have an user control which contains a single RadCombobox.  This is the code.

    <tlrk:RadComboBox
     ID="InternalComboBox"
     runat="server"
     HighlightTemplatedItems="true"  >
     <ItemTemplate>
     <div onclick="StopPropagation(event)" >                                   
      <asp:CheckBox ID="ComboCheckBox" runat="server" CssClass="formTextElevenPx" style="vertical-align: middle;" />
      <span id="CheckBoxLabel" runat="server"><%# DataBinder.Eval(Container, "Text")%></span>
     </div>
     </ItemTemplate>
    </tlrk:RadComboBox>

    I use some Javascript in this page and in my page_prerender event I call the javascript.

    <script type="text/javascript">
     
    function StopPropagation(e) {
      //cancel bubbling
      e.cancelBubble = true;
      if (e.stopPropagation) {
       e.stopPropagation();
      }
     }
     
     function onCheckBoxClick_<% =uniqueKey %>() {
      var combo = $find("<%= InternalComboBox.ClientID %>");
       UpdateMessage(combo);
     }
     function UpdateMessage(combo) {  
      var items = combo.get_items();
      var text = "";
      for (var i = 1; i < items.get_count(); i++) {
       var item = items.getItem(i);
       var chk1 = $get(combo.get_id() + '_i' + i + '_ComboCheckBox');
       if (chk1.checked)
        text+= item.get_text() + ", ";
      }
      return text.trim();
     }
     
    </script>

    I call this Javascript in the onclick event of the RadComboCheckbox like this -
    protected string uniqueKey;
     protected void Page_PreRender(object sender, EventArgs e)
     
      this.uniqueKey = Guid.NewGuid().ToString("N");
      foreach (RadComboBoxItem i in InternalComboBox.Items)
      {
       CheckBox cbx = i.FindControl("ComboCheckBox") as CheckBox;
       if (cbx != null)
       {
        cbx.Attributes["onclick"] = "return onCheckBoxClick_" + uniqueKey + "()";
       }
      }

    So I call the javascript in the cbx.Attributes["onclick"] event.  

    This user control when placed in a normal page works without any issues.  But when I place the usercontrol inside a Radwindow then the javascript associated with the usercontrol -onCheckBoxClick will not load and it shows an Reference not found javascript error.  Why does this happen and how would I fix it.  Would appreciate any help you can provide me.

    Thanks
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 10 Oct 2014 Link to this post

    Hello,

    I am afraid that I am not able to replicate such issue. Could you please send us a sample page that replicates the issue? This way we can investigate it thoroughly and find the problem.

    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top