C validating tutorial

To accomplish this task successfully, first open your project in the solution explorer, right click-new item, in the ‘data’ categories, there is a type named ‘LINQ To SQL Classes’. We will get a file created along with designer interface.

c validating tutorial-69

Another thing I like to do is to display the validation error message on the form in an otherwise hidden field: The problem with our last solution is that if the user saves a partially filled form, and picks it up at a later time, that error message that popped up is long gone, and the only indication that there is something wrong with the form is the modified field color.

So, having a text field contain that error message might be a good idea.

Next, notice one of the most useful advantage of LINQ, if you make any kind of data type mistake in your code, you will be notified immediately while compiling your project.

This will saves lots of your debugging time and lessen the db errors at the same time.

To start, we create a text field and bring up the properties dialog for the field.

Then we select the “Validate” tab to see the validation options: The default is that the field will not get validated.

In that case, the previous value of the field is restored, and the user has to enter the data again.

This is not always desired (for more complicated data, it will probably be much easier to take a look, correct that one typo and continue with the rest of the form), so my preference is actually to mark the field so that the user knows which field needs to be corrected, and have the validation script not report a validation error back to the field: Using this method has implications on the form submission process: The form no longer can verify that the data is correct, so the submission function needs to do another round of validation to see if any of the required fields are not correct (one way to do that is to test all relevant fields to see if the text color is using the error color, or we can use global variables to store the validation state).

tutorial overview, then how to get started very quickly with its usage on our C#.

Comments are closed.