Solved

My range validator is not working

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

747 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

12 Experts available now in Live!

Get 1:1 Help Now