What is the purpose of InvalidStyleDuration on a RadTextBox?

0 Answers 20 Views
Input
Peter
Top achievements
Rank 1
Peter asked on 22 Jan 2024, 05:41 PM

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.

 

 
Peter
Top achievements
Rank 1
commented on 22 Jan 2024, 05:57 PM

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.

Peter
Top achievements
Rank 1
commented on 22 Jan 2024, 06:00 PM

Well, actually the question remains... the Invalid Style goes away when the field is clicked, which is good enough.  But it's still unclear what the purpose of InvalidStyleDuration is, since it doesn't appear to work.
Rumen
Telerik team
commented on 24 Jan 2024, 11:52 AM

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. 

No answers yet. Maybe you can help?

Tags
Input
Asked by
Peter
Top achievements
Rank 1
Share this question
or