NumericTextBox Validation Question

3 posts, 1 answers
  1. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jul 2012

    Posted 05 Oct 2012 Link to this post


    My team is having an issue with the NumericTextBox and the developer currently having the issue asked that I post his question in the forum on his behalf since he is having a technical issue with his workstation that is preventing him from posting himself.

    "I have a NumericTextBox that has MinValue and MaxValue properties.I have a ValidationSummary control which has a RequiredFieldValidator connected to another TextBox control.

    When the user hits the Save button and validation takes place, is there a way for invalid values in the NumericTextBox control, for example value entered is less than the MinValue, to be displayed in the ValidationSummary control without hooking up an additional validation control?"



  2. Answer
    Angel Petrov
    Angel Petrov avatar
    1044 posts

    Posted 10 Oct 2012 Link to this post

    Hi Andrew,

    The desired logic is not supported because when setting MinValue and MaxValue the RadNumericTextBox auto corrects the data. You could use a RangeValidator instead and that way you would be able to display the validation summaries. This approach is shown in the following code snippet:
    <telerik:RadNumericTextBox runat="server" ID="RadNumericTextBox1" >
        <asp:RangeValidator ID="NumericTextBoxRangeValidator" runat="server" ControlToValidate="RadNumericTextBox1"
        errormessage="Year number should be a non negative less than 100."
        MaximumValue="100" MinimumValue="0" Type="Integer" />
        <asp:TextBox ID="TextBox1" runat="Server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="req1" runat="Server" ControlToValidate="TextBox1"
        errormessage="Please enter your name!"
        Text="<br>Please write something in 2nd  Box."></asp:RequiredFieldValidator>
        <asp:Button ID="btnSubmit" runat="Server" OnClick="WriteTextBoxValue" Text="Submit" />            
        <asp:ValidationSummary ID="ValidationSummary" runat="Server"
        ShowSummary="true" EnableClientScript="true"  DisplayMode="List"
        HeaderText="Following error occured." />

    All the best,
    Angel Petrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jul 2012

    Posted 15 Oct 2012 Link to this post

    This worked great for us, thanks a lot!

Back to Top