I am using a RadTextBox for a simple messaging form, and if the user leaves a field blank, I use a CustomValidator to set the control IsValid=true. This is great and it uses the invalid style (pink background) and little icon and brings the user's attention to the field.
protected void valMissingFields_ServerValidate(object source, ServerValidateEventArgs args) { txtMessageSubject.Text = txtMessageSubject.Text.Trim(); txtMessageBody.Text = txtMessageBody.Text.Trim(); txtMessageSubject.Invalid = (txtMessageSubject.Text == ""); txtMessageBody.Invalid = (txtMessageBody.Text == ""); args.IsValid = (!txtMessageSubject.Invalid && !txtMessageBody.Invalid); }
I thought the InvalidStyleDuration would make it go away after a few seconds (3000 ms = 3 seconds):
<table cellspacing="0" cellpadding="0" style="width:100%;">
<tr valign="top">
<td style="width:90px;">
Message:
</td>
<td>
<telerik:RadTextBox ID="txtMessageBody" runat="server"
Width="100%" MaxLength="1000" TextMode="MultiLine" Rows="25"
InvalidStyleDuration="3000"
EnableEmbeddedSkins="false" Skin="MyCustomSkin"></telerik:RadTextBox><br />
</td>
<td style="width:20px; text-align:right;">
<span class="required">*</span>
</td>
</tr>
</table>
But it does not.
Instead, the user is stuck typing into the text box with bright red bold lettering.
Am I misunderstanding how this works?
As a workaround, I thought I'd use the OnClientEvents for OnValueChanging to make it switch the Invalid indication off, but apparently that event only fires when focus moves away from the control.
OK, never mind. I went into the extensions for Telerik from Visual Studio and just re-updated, and everything reset back to normal. While running into the problem listed here, I had also noticed that RadTextBox.Text values were always blank, so I could not read them! So something was definitely funky.
Seems it got fixed when I reset the extensions.
The InvalidStyleDuration property is used to determine how long (in milliseconds) the input control will display its invalid style when incorrect data is entered. Must be a positive integer.
My investigation shows that the property works only when the RenderMode property is set to Classic. For your convenience, I have attached a short video demonstrating how it works.
To fix the problem in Lightweight mode, you can put the following class on the page or in the site stylesheet imported in the page:
<style> html body .RadInput_Silk .riError, html body .RadInput_Error_Silk { border-color: red !important; color: red !important; } </style>
If you are using another skin put it on the place of Silk, e.g.
.RadInput_Default, .RadInput_Error_Default
Test and let me know how it goes.