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.
Then in a handler for the ClientEvents-OnKeyPress event I call this to set the background color back.
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.
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.