473,396 Members | 1,898 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,396 software developers and data experts.

How to validate fields on the form in C#

I have a form with a number of fields, some of which would be
filled(populated) automatically from the MS SQL database on certain
event.Now, I have certain validations on the fields from sql database
as constraints(eg. format of the tel number), So I was wondering how do
I catch these runtime exceptions which r likely to occur if the user
enters something which violated the sql constraints.

Also, on my form, the user can also change the information (which is
populated by the sql database), this information after submitting goes
back into the database which has constraints. So, I would like to
validate this info b4 Sql throws exception.

Any idea how to approach over this??

Mar 10 '06 #1
2 2212
Controls that take user input will typically have a Validating event that
you can use to check the data the user entered.

"juventusaurabh" <sa************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
I have a form with a number of fields, some of which would be
filled(populated) automatically from the MS SQL database on certain
event.Now, I have certain validations on the fields from sql database
as constraints(eg. format of the tel number), So I was wondering how do
I catch these runtime exceptions which r likely to occur if the user
enters something which violated the sql constraints.

Also, on my form, the user can also change the information (which is
populated by the sql database), this information after submitting goes
back into the database which has constraints. So, I would like to
validate this info b4 Sql throws exception.

Any idea how to approach over this??

Mar 10 '06 #2
You could use a validator control to check the values before they are
submitted to SQL.

Technically, this checking should occur wherever your business logic
rules exist (UI, Business Layer etc) so that once your business rules
run against the input, you can throw an appropriate exception and
display it to the user.

Mar 10 '06 #3

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

Similar topics

1
by: Techy | last post by:
I have two fields in my form so called : invoice and cash Now I want to validate this form on the client side with the help of javascript in such a way that if one of these fields is empy an...
11
by: wolf | last post by:
There are three webcontrol on my asp.net form: a TextBox, a submit button and a RegularExpressionValidator. And I had set ControlToValidate property of the RegularExpressionValidator to the...
4
by: Wysiwyg | last post by:
I need to validate a form to ensure that all of the fields add up correctly. I can't do this while the user is entering data since validation needs to be done after the entry is completed. What's...
11
by: TokyoJ | last post by:
I run a small camp in Alaska for kids and my director is asking for a web form. Could someone please have a look and offer some advice on where I'm making mistake(s)? I'm using the RegExp function...
2
by: Neo Geshel | last post by:
Greetings, I have a form with a telephone field. It is very specific, as it has four text boxes - the country code, area code, prefix and suffix. I can validate each of them individually, but...
5
by: phpCodeHead | last post by:
I am needing to determine how to go about validating that a field in my form contains only a positive integer. I know that this is fairly simple if the form contains only one element to be...
5
nathj
by: nathj | last post by:
Hi, I have been looking around the forum and the web for a way to achieve this and so far I have drawn a blank. So I head to the forum as I'm sure someone knows how to do this. I have a form...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
2
by: Mick Walker | last post by:
Hi, I have a problem that I have been trying to figure for a couple of days, and am wondering if anyone out there would be so kind as to give me a solution. (Deadline time) I am trying to...
4
by: jmartmem | last post by:
Greetings, I have an ASP page containing a Record Insertion Form with a number of fields (mostly text fields and list/menu fields) linked to an Access database. I've created an onsubmit behavior...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.