?
Solved

My range validator is not working

Posted on 2008-10-23
3
Medium Priority
?
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
Bane83 earned 2000 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

Industry Leaders: 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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 …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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