I have a pretty simple ASP.NET page with some input fields and validators. A single field accepting a double is as follows:
<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 properly (some strange errors in the project). See comments for answers below for more details.
Then I will 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 for 'vdGrossTonnage' cannot be converted to an Integer type.
I do not have any specific requirements for the maximum value in the system, so I would just like the default for Int32.MaxValue (although I would have to enter 2,147,483,647, since MaximumValue does not seem to accept the Int32.MaxValue constant).
Why RangeValidator t RangeValidator type Integer not accept the missing MaximumValue property, but is it normal for one of the Double types?
Nailuj
source share