|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
RangeValidator
I want to use a integer range validator for a text box, but I want to set the maximum value at the end of Page_Load rutine, because it's the moment I know it's value.<br><br>How can I do this?
|
|
#2
|
||||
|
||||
|
Assuming that the name of the validator is "RangeValidator1":<br><br>Set the RangeValidator1's "type" property to "Integer". Then try adding this to the page load routine"<br><br>int x = 200; // or whatever number you set x to be<br>RangeValidator1.MaximumValue = x.ToString();<br><br>Hope this helps.<!-- Edit --><p><i>Last Edited : 5/13/2003 7:00:28 PM GMT</i></p>
|
|
#3
|
|||
|
|||
|
If I don't provide in the aspx a value for MaximumValue attribute I get the following exception:<br><br>Exception Details: System.Web.HttpException: The value '' of the MaximumValue property of 'IssuesRangeValidator' cannot be converted to type 'Integer'<br><br>If I set the MaximumValue to let's say 100 in the aspx, and in the code behind page to 50, it uses 100 to validate my control.<br> <img border="0" src="/forum/emoticons/mad.gif" height="15" width="15" alt="mad" />
|
|
#4
|
||||
|
||||
|
The exception is appearing because the MaximumValue has to be a string. (but it can still validate the string as a number)<br><br>Follow these steps:<br><br>1) Clear out the Max and Min values in the ASPX to 0 - for the range validator. <br>2) In the ASPX, set the type property to "Integer".<br>3) Type in this code in the PageLoad()<br><br>RangeValidator1.MinimumValue = "1";<br>RangeValidator1.MaximumValue = "100";<br><br>This works on my system. Hope it works for you, Danny
|
|
#5
|
|||
|
|||
|
Nice!!! <br>Now when I tried to submit this message and I get a exception error on the forum <br> <img border="0" src="/forum/emoticons/tongue.gif" height="15" width="15" alt="tongue" /> <br><br>Seems that not only I have problems with the .NET
|
|
#6
|
|||
|
|||
|
Still not working!<br><br>My code-behing source in page load is (VB.NET):<br><br> IssuesRangeValidator.Type = ValidationDataType.Integer<br> IssuesRangeValidator.MinimumValue = "1"<br> IssuesRangeValidator.MaximumValue = "50"<br><br>In the aspx file I have the following:<br><br> <div class="msgQuoteWrap"><div class="msgCode">asp:RangeValidator runat="server" ID="IssuesRangeValidator" ControlToValidate="txtPage" ForeColor="#cc0033" ErrorMessage="Value is out of range!"</div></div><br><br><br><br>I don't get any error, but oon any value I get the message "Value is out of range!" (I tryed 1, 50, 100, 100, 4)<br><br> <img border="0" src="/forum/emoticons/mad.gif" height="15" width="15" alt="mad" /> <br><br>Nice!!! <br>Now when I tried to submit this message and I get a exception error on the forum <br> <img border="0" src="/forum/emoticons/tongue.gif" height="15" width="15" alt="tongue" /> <br><br>Seems that not only I have problems with the .NET
|
|
#7
|
||||
|
||||
|
Hmm... If you give me your email, I will send you my working example. It's in C#, but should work the same.
|
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > RangeValidator |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|