Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:45:27+00:00 2026-05-20T18:45:27+00:00

I have a pretty simple ASP.NET page with some input fields and validators. One

  • 0

I have a pretty simple ASP.NET page with some input fields and validators. One field accepting a double looks like this:

<asp:TextBox ID="tbHeight" runat="server" />
<asp:RangeValidator ID="vdHeight" runat="server" 
    ErrorMessage="Height must be a positive number" Text="*" 
    ControlToValidate="tbHeight" MinimumValue="0" Type="Double" />

This works as expected, and the user must enter a number >= 0.
Update: this does not work as expected afterall (some weird bug in the project). See comments to the answers below for details

I then try the same for a field accepting an integer:

<asp:TextBox ID="tbGrossTonnage" runat="server" />
<asp:RangeValidator ID="vdGrossTonnage" runat="server" 
    ErrorMessage="Gross Tonnage must be a positive whole number" Text="*" 
    ControlToValidate="tbGrossTonnage" MinimumValue="0" Type="Integer" />

When loading the ASP-page, this gives me the following error: The value ” of the MaximumValue property of ‘vdGrossTonnage’ cannot be converted to type ‘Integer’.

I don’t have any specific max value requirements in the system, so I would just like it to “default” to Int32.MaxValue (although I’d have to enter 2,147,483,647, since MaximumValue doesn’t seem to accept the Int32.MaxValue constant).

Why is it that a RangeValidator of the type Integer won’t accept a missing MaximumValue property, but for one of the type Double this is ok?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:45:27+00:00Added an answer on May 20, 2026 at 6:45 pm

    The MinimumValue and MaximumValue properties of the RangeValidator class return string.Empty as their default when not set.

    Next, it also happens that the Convert() protected method implemented by BaseCompareValidator, which is used for converting the string properties to values, calls int.Parse() for the ValidationDataType.Integer case. int.Parse() doesn’t like the empty string and will throw an exception.

    But, in the case of ValidationDataType.Double, Convert() first calls another protected method, ConvertDouble() (instead of double.Parse()), and in that method it explicitly returns a string value of “0” when an empty string is detected, and that string value “0” later parses, via double.Parse() into 0d.

    The integer case doesn’t benefit from such a mapping of string.Empty to “0”.

    Hence, the dicrepancy. The devil is in the details, and Reflector is your friend.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one should be pretty simple. I am making a non-MVC ASP.NET 2.0 site.
I've been working in ASP.NET- just starting out, and I have a pretty simple
I have a very simple application which consists of an ASP.NET front end site,
We have a classic ASP page that is instantiating a .Net object through a
I am confused about something really simple in ASP.NET. I have seen many times
I have some existing (largish) ASP.NET web applications that people are starting to visit
I have a simple ASP.NET table like so: <asp:Table id=tbl> <asp:TableHeaderRow id=header> <asp:TableHeaderCell id=hcell1
Should be pretty simple: I have an InputStream where I want to peek at
Pretty simple question: When i have a persistable object, it usually has a property
Pretty simple scenario. I have a web service that receives a byte array that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.