change forecolor dynamically

5 posts, 0 answers
  1. Bharani Mani
    Bharani Mani avatar
    40 posts
    Member since:
    Dec 2009

    Posted 24 Dec 2009 Link to this post

    Hello,
            Wish you all merry christmas and a happy new year.  I want to change the color of the text in a RadTextBox control dynamically OnMouseOut. I want to do it on Client-Side. I checked the Input styles properties. and I didnt see any method to set the style of input. I saw get_style() but not set_style, not sure how to do it..


    Thanks,
    Bharani
  2. Steve
    Steve avatar
    1888 posts
    Member since:
    Dec 2008

    Posted 27 Dec 2009 Link to this post

    You should be able to get it done with some quick jQuery

    http://docs.jquery.com/CSS/css#namevalue

        $telerik.$("#'<%=myTextBox.ClientID %>'").mouseover(function () {
          $telerik.$(this).css("color","red");
        });
    
    
    Here's the events you can use
    http://docs.jquery.com/Events

    jQuery comes embedded into most of the telerik components, just make sure to use $telerik.$ instead of just $.

    Give it a try, you can do some awesome stuff with jQuery, and like I said, it comes built into the Telerik.Web.UI anyway!

    Steve
  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Dec 2009 Link to this post

    Hello Bharani,

    You can set styles for the datepicker as shown below:
    js:
    function MouseOut(sender,args) 
        { 
           sender.get_styles().EnabledStyle[0] += "background-color: lightblue;"
           sender.updateCssClass(); 
        } 

    Check out the section 'Changing the appearance style of RadInput controls on the client' of the following document for more information:
    Client-Side Basics

    Thanks
    Princy.
  4. Bharani Mani
    Bharani Mani avatar
    40 posts
    Member since:
    Dec 2009

    Posted 28 Dec 2009 Link to this post

    Hello Princy,
             I did try your way of setting the forecolor of the textbox but didnt work.

                sender.get_styles().EnabledStyle[0] += "ForeColor: red";
                sender.updateCssClass();



         
    Am I doing anything wrong?

    Thanks,
    Bharani
  5. Dimo
    Admin
    Dimo avatar
    8482 posts

    Posted 28 Dec 2009 Link to this post

    Hi Bharani Mani,

    ForeColor is a server-side ASP.NET property. The corresponding CSS property is color.

    Please make yourself familiar with the CSS properties at

    http://www.w3.org/TR/CSS21/propidx.html

    Sincerely yours,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top