Solved

My range validator is not working

Posted on 2008-10-23
3
331 Views
Last Modified: 2010-08-05
I have a textbox control within a update panel that I need to validate. Why is the validation not working.
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
           <ContentTemplate>
               <asp:RangeValidator ID="RangeValidator3"
                ControlToValidate="LoadNumberListBox"
                Type="Integer"
                 MaximumValue="5000000"
                  MinimumValue="1"
               runat="server" ErrorMessage="Please enter your load number"
                   
                   style="top: 500px; left: 505px; position: absolute; height: 16px; width: 206px"></asp:RangeValidator>
            <asp:Label ID="loadLabel" runat="server"
            style="top: 521px; left: 473px; position: absolute; height: 16px; width: 103px"
            Text="<b>Load Number:</b>"></asp:Label>          
           
               <asp:ListBox ID="LoadNumberListBox"
               style="top: 520px; left: 576px; position: absolute; height: 30px; width: 128px"
               
                runat="server" DataSourceID="SqlDataSource10" DataTextField="OrderID"
                   DataValueField="OrderID" AppendDataBoundItems="True"></asp:ListBox>
           
               <cc1:ListSearchExtender ID="LoadNumberListBox_ListSearchExtender"
                   runat="server" Enabled="True" TargetControlID="LoadNumberListBox">
               </cc1:ListSearchExtender>
0
Comment
Question by:soccerman777
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
Bane83 earned 500 total points
ID: 22787717
RangeValidator only validates range and doesn't care if no item is selected.  You'll also need a RequiredFieldValidator, but in order to use this, you'll also need to add an extra item to the list such as "Select:" with a value which won't be in your range (-1 as an example) and the RequiredFieldValidator will need to have InitialValue="-1" (or whatever value you give to the new item.
0
 

Author Comment

by:soccerman777
ID: 22788205
Sorry bane I should have put that in my first post. I am using  
LoadNumberListBox.Items.Insert(0, New ListItem("Choose...", ""))

I also have a required field validator however since you mentioned it I realized that it was not in the update panel so it was not working I put it into the update panel and they both work. I am sure you would have saw that if I had put all of the code in my question.

THANKS
0
 

Author Closing Comment

by:soccerman777
ID: 31509272
Sorry bane I should have put that in my first post. I am using  
LoadNumberListBox.Items.Insert(0, New ListItem("Choose...", ""))

I also have a required field validator however since you mentioned it I realized that it was not in the update panel so it was not working I put it into the update panel and they both work. I am sure you would have saw that if I had put all of the code in my question.

THANKS
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now