Discussion:
Input validation
Gabriel
2007-05-14 08:13:25 UTC
Permalink
Hello,

How can I check the validity input for a check box, I'd like to be sure then
the user put a number and not a string, how can I do that ?

In the code-behind too (with tryparse) but in the GUI ? is there a right way

for the decimal, I have to cjeck if decimal separator is . or , in my
country is ,


Regards,

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Densial Edmonds
2007-05-15 20:25:38 UTC
Permalink
Go to ajax.asp.net, scroll down the page and click on "watch more
asp.net ajax videos" and watch #13 (How Do I: Use the ASP.NET AJAX
Client Library Controls), use regexp to check for a valid number

Densial Edmonds

Conduit International Limited
15 Church Street, Onehunga
Private Bag 92816, Penrose
Auckland

Ph : +64 (9) 915 9100
DDI : +64 (9) 915 9128
Fax : +64 (9) 915 9101
Mob : +64 (27) 293 8410

email : ***@thewebconduit.com
website : www.thewebconduit.com

"If I'd had more time I'd have written less code."

CAUTION - This message may contain privileged and confidential
information intended only for the use of the addressee named above.
If you are not the intended recipient of this message you are hereby
notified that any use, dissemination, distribution or reproduction of
this message is prohibited.
If you have received this message in error please notify Conduit
International Limited immediately.
Any views expressed in this message are those of the individual sender
and may not necessarily reflect the views of Conduit International
Limited.
-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
Sent: Monday, 14 May 2007 8:13 p.m.
Subject: [DOTNET-WEB] Input validation
Hello,
How can I check the validity input for a check box, I'd like to be
sure
then
the user put a number and not a string, how can I do that ?
In the code-behind too (with tryparse) but in the GUI ? is there a
right
way
for the decimal, I have to cjeck if decimal separator is . or , in my
country is ,
Regards,
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Gabriel
2007-05-16 06:30:19 UTC
Permalink
Post by Densial Edmonds
Go to ajax.asp.net, scroll down the page and click on "watch more
asp.net ajax videos" and watch #13 (How Do I: Use the ASP.NET AJAX
Client Library Controls), use regexp to check for a valid number
and without Ajax ?

Thanks,

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Efran Cobisi
2007-05-16 07:46:23 UTC
Permalink
Hi Gabriel,

Basically there are two ways you could follow. Assuming you have to
validate a string which should be a representation of a double:

a) Use a CompareValidator [1], setting the Operator property [2] value
as DataTypeCheck and the Type property value as Double. This solution
involves writing not a line of code... The only drawback is it would be
not so easy to deal with globalization issues: in fact, this control
would parse the target string with the culture information of the
current thread (or with a neutral culture, if the control is properly
instructed to do so).
b) Implement your own CustomValidator [3] and attempt to parse the
validation property of the target control via, for example,
System.Double.TryParse(). Naturally this one gives you the greatest
control over the validation logic; since you have to implement this
logic, you can, for example, parse the target string with a given
culture information, thus overcoming the limitations of the former.

[1] http://msdn2.microsoft.com/en-us/library/db330ayw(VS.71).aspx
[2]
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.validationcompareoperator.aspx
[3]
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.aspx

Hope this helps.

--
Efran Cobisi
http://www.cobisi.com
Post by Gabriel
Post by Densial Edmonds
Go to ajax.asp.net, scroll down the page and click on "watch more
asp.net ajax videos" and watch #13 (How Do I: Use the ASP.NET AJAX
Client Library Controls), use regexp to check for a valid number
and without Ajax ?
Thanks,
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Paul van Brenk
2007-05-16 09:12:53 UTC
Permalink
System.Web.UI.WebControls.RegularExpressionValidator or System.Web.UI.WebControls.CompareValidator

Paul

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Gabriel
Sent: Wednesday, May 16, 2007 08:30
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] Input validation
Post by Densial Edmonds
Go to ajax.asp.net, scroll down the page and click on "watch more
asp.net ajax videos" and watch #13 (How Do I: Use the ASP.NET AJAX
Client Library Controls), use regexp to check for a valid number
and without Ajax ?

Thanks,

===================================
This list is hosted by DevelopMentor(r) http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Loading...