I chose this show as I remembered it had a lot of small interesting points. The show dealt with: -
- commonly overlooked features of ASP.NET Validators
- requiring that at least 1 textbox has text
1. commonly overlooked features of ASP.NET Validators
========================================
a) Validate a TextBox as a Date. As an aside, Personally I prefer CSLA framework concept where you can use 't' for today and 't-' for yesterday and 't+' for tomorrow etc)
Add a CompareValidor; properties;operator;change to DateTypeCheck;change type to Date
Operator="DataTypeCheck" Type="Date">
b) Validator Culturised (Australianised, Americanised, Ukise etc)
===============================================
Validators all follow current pages culture info object. The culture can be changed by
properties -> document -> culture
c) How to Prevent a Button from Validating
===============================
For example have a two buttons on a form (OK andCancel). You want OK to validate and Cancel not to validate.
button=>properties=>CausesValidation=>set it to false
The button will no longer provide client or server side validation.
A textbox also has a CauseValidation property. However this is part of the AutoPostBack. Thus the property name should include AutoPostBack as well as CausesValidation.
d) Server Side Validation Must be setup for it to Work
======================================
Server side validation is important to validate data against business object or database data. If you fail to do server side validation then you can be hacked. The hacked will turn off java script and then have easy access.
To setup server side validation is easy (for example):-
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
//save data
}
}
2) requiring that at least 1 textbox has text
===============================
Please see the screencast for further details - as this blog is getting too long
No comments:
Post a Comment