This is a migrated thread and some comments may be shown as answers.

RadTextBox updateCssClass not updating

2 Answers 107 Views
Input
This is a migrated thread and some comments may be shown as answers.
Marbry
Top achievements
Rank 1
Marbry asked on 17 Aug 2011, 03:09 PM
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;", "");
sender.updateCssClass();

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 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 22 Aug 2011, 09:53 AM
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,
Tsvetina
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 >>

0
Marbry
Top achievements
Rank 1
answered on 22 Aug 2011, 02:54 PM
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.
Tags
Input
Asked by
Marbry
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Marbry
Top achievements
Rank 1
Share this question
or