Validating textbox

Malicious users might circumvent client side validations in an effort to break-in or damage your servers.

Simply put, never trust the data in an incoming request, and always validate on the server.

In the Properties dialog box find the Control To Validate property and select First Name Text Box from the drop down list. We can set other properties, such as the Error Message property, and the final ASPX source code should look like the following. NET work in a similar fashion to what we've seen above. If the client's web browser is of executing client side Java Script, the first validation pass occurs on the client.

The cancel button has a Causes Validation property. As we mentioned in the beginning of the article, validation can occur twice: once on the client’s machine and once on the server. Client side validation provides quick feedback for the user.

Listing 3: Validation for all letters Figure 3: Above output checks the entered data is letters or include any other char also. Two of them are using regular expression for matching and the other one is simple so not writing regex but if you want you can write a regex for this case also.

Not executing server side validation leaves your application code vulnerable to malicious users.All of the validation controls derive from the Base Validator class, giving them common methods and properties.As we mentioned earlier, validation controls execute when the user clicks a Button control, including HTML button controls and server button controls such as the Link Button and Image Button.When validation fails the normal flow of execution continues.You need to check the Is Valid property to know if a validation check failed.

Leave a Reply