473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I validate the values entered for custom control properties?

I have a custom control with properties named MinValue, MaxValue, and Value
(all of which I have assigned a DefaultValue design-time attribute). The
Value property must be between (or equal to) the MinValue and MaxValue
properties in order to avoid a runtime error. I want to give an error during
the usage of the control stating this, as well as prevent it from compiling
under these conditions. Because this is something I have never done with
custom controls before, I need some help here. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jul 21 '06 #1
2 1202
One way would be to throw an exception if the value is out of range - Visual
Studio will catch this exception and not allow the user to change to invalid
values.
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : Drop-In Explorer GUI Controls For Your Apps (.Net & ActiveX
Editions Available)
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions rapidly in .Net
---------

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:Ol**************@TK2MSFTNGP02.phx.gbl...
>I have a custom control with properties named MinValue, MaxValue, and Value
(all of which I have assigned a DefaultValue design-time attribute). The
Value property must be between (or equal to) the MinValue and MaxValue
properties in order to avoid a runtime error. I want to give an error
during the usage of the control stating this, as well as prevent it from
compiling under these conditions. Because this is something I have never
done with custom controls before, I need some help here. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jul 21 '06 #2
That will not work in all situations. For example, if the current values are
MinValue=75, MaxValue=100, Value=80 and the user wants to change them to
MinValue=25, MaxValue=50, Value=40. This will force the user to change them
in a certain order, which could be very annoying. I want the user to be
notified, but still be allowed to change them, and simply not be allowed to
compile it if they are out of range. Also, if I did use your exception idea,
where in my code would I put it? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"G Himangi" <in**@ssware.comwrote in message
news:em**************@TK2MSFTNGP04.phx.gbl...
One way would be to throw an exception if the value is out of range -
Visual Studio will catch this exception and not allow the user to change
to invalid values.
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : Drop-In Explorer GUI Controls For Your Apps (.Net &
ActiveX Editions Available)
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions rapidly in .Net
---------

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:Ol**************@TK2MSFTNGP02.phx.gbl...
>>I have a custom control with properties named MinValue, MaxValue, and
Value (all of which I have assigned a DefaultValue design-time attribute).
The Value property must be between (or equal to) the MinValue and MaxValue
properties in order to avoid a runtime error. I want to give an error
during the usage of the control stating this, as well as prevent it from
compiling under these conditions. Because this is something I have never
done with custom controls before, I need some help here. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


Jul 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hernán Castelo | last post by:
hi should i validate cookies values? thanks -- atte, Hernán Castelo SGA - UTN - FRBA
0
by: Mark | last post by:
Hi, I am playing around with creating custom server controls for use within a ASP.NET page. I am creating a contact form and have the following question I am capturing the form postback data...
7
by: Paul | last post by:
Hi, I have a form where a user is required to enter a start date and an end date. Both are required and must between a specific date range (e.g. 01/01/1900 and 01/01/2099) and the end date...
4
by: owingruters | last post by:
Hi all, I've created an User control. It's an extension of a textbox wich has some extra properties so that validation becomes a lot faster. The control wordks great if autopostback is on....
0
by: Mark | last post by:
Hi, I am playing around with creating custom server controls for use within a ASP.NET page. I am creating a contact form and have the following question I am capturing the form postback data...
3
by: Martin | last post by:
Hi, I am implemeting a form in asp.net. The form is quite large and the validation is reasonably complex, so I have decieded to implement my own validation rather than use any custon...
4
by: Jon Paal | last post by:
I have a custom server control which renders some html. I want to capture some interim values generated by the control as it processes the data. is there a way to capture and retrieve the...
2
by: Nathan Sokalski | last post by:
I have a custom control with properties named MinValue, MaxValue, and Value (all of which I have assigned a DefaultValue design-time attribute). The Value property must be between (or equal to) the...
11
by: jjbutera | last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate the values and set the ErrorProvider in the validating event. If not valid, I set e.Cancel = True. I clear the ErrorProvider...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.