[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need to restrict input to positive integer numbers between 1 and 100 inclusive

Posted on 2011-02-23
4
Medium Priority
?
875 Views
Last Modified: 2012-05-11
I have an asp.net text box. I need restrict the application user to entering only positive integer values greater than Zero and less than or equal to 100. What is the best way to do this not using Java Script? But using Asp.net? If a regular expression is the best way, I am open to that, but I will need some help.
0
Comment
Question by:brgdotnet
[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
4 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 34966995
Use an ASP.net rangevalidation control
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 600 total points
ID: 34967003
0
 

Assisted Solution

by:sshull
sshull earned 600 total points
ID: 34967004
Honestly, Javascript would be best since it can be done on the client side but if you must use ASP.net, in the OnClick event of your submit button you can validate it by using the following:

Dim intValue As Integer

Try 
' Verify Integer
intInteger = CInt(textboxname.text.trim)
' Verify Between Values
If intInteger <0 OR intInteger > 100 Then
lblError.text = "Invalid Value. Must Be Between 1 and 100."
Exit Sub

' Other Processing Rules...
End If
Catch ex As Exception
lblError.text = "Invalid Integer
Exit Sub
End Try

Open in new window


lblError is just a label on your form to display the error message to the user.
0
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 34969967
Thank you!
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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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 …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

649 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