Solved

My range validator is not working

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 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