Need to change backcolor of combobox.

4 posts, 0 answers
  1. hchattaway
    hchattaway avatar
    67 posts
    Member since:
    Feb 2007

    Posted 03 Sep 2008 Link to this post

    Hello

    I am looking to change the color of one combobox when the value of another combobox changes.

    i.e. cmbOne is changed from "Select..." to "Entered Date", on the client side, I'd like to change the backcolor of cmbTwo to red to show it is now required... Any examples of how to do that?

    This is the script I am using now... it can not resolve the $find("cmbCompare") statement in line 4, even though that control exists on the page...I have this hooked up to the "onselectedindexchanged" client event.

    1 <script language="javascript" type="text/javascript"
    2     //<![CDATA[ 
    3     function SetCompareRed(sender, eventArgs) { 
    4         var compareChoice = $find("cmbCompare"); 
    5         compareChoice.BackColor = "Red"
    6     } 
    7     //]]> 
    8 </script> 

    Thanks for any help!
    Harold
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 03 Sep 2008 Link to this post

    Hi hchattaway,

    Please try finding the combobox in this way:

    var compareChoice = $find("<%= cmbCompare.ClientID %>");  

    Also, please check this help article:
    Tutorial: Change the appearance of the Input element

    I hope this helps.

    Kind regards,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. hchattaway
    hchattaway avatar
    67 posts
    Member since:
    Feb 2007

    Posted 03 Sep 2008 Link to this post

    Hello
    <<
      var
     compareChoice = $find("<%= cmbCompare.ClientID %>"); 
    >>

    I had done that before but when I do I get this error when the page is loading...

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    I believe this is happening since this is in an ascx file in a DNN app, and this JS function is inside the FORM tag.. so it's being run during form load...How can I get that above the starting FORM tag if that is indeed the issue?

    Thanks for the help!
    Harold


  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 04 Sep 2008 Link to this post

    Hello hchattaway,

    Please try wrapping the javascript within RadCodeBlock.

    Kind regards,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top