LoadOnDemand RadComboBox in a UserControl

5 posts, 0 answers
  1. Thomas
    Thomas avatar
    143 posts
    Member since:
    Feb 2007

    Posted 09 Sep 2008 Link to this post

    I have a RadComboBox in a UserControl. The RadComboBox has EnableLoadOnDemand = true. How do I get the value of the combobox on the client side from a parent page or container control? I have tried:

    var foo = $find('<%=this.UserControlInstanceName.ClientID %>');
    foo.get_value();
    foo.get_text();

    and

    var foo = $find('<%=this.UserControlInstanceName.FindControl("RadComboBoxName").ClientID %>');
    foo.get_value();
    foo.get_text();

    In both cases, it simply returns the default of the combo box instead of what is current set.
  2. Thomas
    Thomas avatar
    143 posts
    Member since:
    Feb 2007

    Posted 10 Sep 2008 Link to this post

    I found the problem and have a solution. The issue is that the call to this.MyUserControl.ClientID returned the ClientID for the UserControl as opposed to ClientID of the ComboBox in the UserControl.

    My solution was to created a public property called "ComboBoxClientID" on the UserControl which returned the ClientID of the ComboBox. My javascript code then looks like:

    var foo = $find("<%= this.MyUserControl.ComboBoxClientID %>");
    foo.get_value();
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 15 Sep 2008 Link to this post

    Hello Thomas,

    Thank you for sharing the approach with the community.

    Another implementation would be to have a global javascript variable:
    var combo;

    and subscribe to the OnClientLoad client-side event and in its handler set:

    combo = sender;


    Regards,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Thomas
    Thomas avatar
    143 posts
    Member since:
    Feb 2007

    Posted 15 Sep 2008 Link to this post

    Hi Veskoni,

    Unfortunately, that approach will not work if there are multiple instances of the UserControl on the same form.
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Sep 2008 Link to this post

    Hi Thomas,

    Yes, absolutely.

    Sincerely yours,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017