Solved

My range validator is not working

Posted on 2008-10-23
3
337 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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