RadTextBox updateCssClass not updating

3 posts, 0 answers
  1. Marbry
    Marbry avatar
    123 posts
    Member since:
    Aug 2012

    Posted 17 Aug 2011 Link to this post

    It's really a two part problem.  This is what I'm doing,

    I call this on the server to set the background color if the input was not considered valid.
    textboxname.Style.Add(HtmlTextWriterStyle.BackgroundColor, "red");

    Then in a handler for the ClientEvents-OnKeyPress event I call this to set the background color back.
    sender.get_styles().EnabledStyle[0] = sender.get_styles().EnabledStyle[0].replace("background-color:red;", "");

    The first problem is that the background color doesn't change until the focus is moved off the text box, when I want it to occur as soon as the user types something into it.

    The second problem is that the color does change if you click off the box, but then it flashes back to red if you mouseover the box and as long as you hold the cursor there.  Mouseout, it goes back to white, back and forth.
  2. Tsvetina
    Tsvetina avatar
    2481 posts

    Posted 22 Aug 2011 Link to this post

    Hello Marbry,

    Unless you have some custom code that checks whether the values is correct on keydown or keypress, the style cannot be updated faster, since the built-in validation of RadTextBox runs when it is blurred out.
    As for changing the styles, you should also change HoveredStyle[0] in order to make the change apply in the case of a mouse over state of the control.

    More information on the different styles and the states of the textbox when they are applied is available here:
    InputStyles Client Object

    Kind regards,
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. Marbry
    Marbry avatar
    123 posts
    Member since:
    Aug 2012

    Posted 22 Aug 2011 Link to this post

    Thanks Tsvetina, that worked a charm.

    I was already calling that from the client keypress event, but I had to also set the FocusedStyle[0] in addition to the HoveredStyle[0] as you mentioned.
Back to Top