Presentation is loading. Please wait.

Presentation is loading. Please wait.

Validation and Rich controls 1www.tech.findforinfo.com.

Similar presentations


Presentation on theme: "Validation and Rich controls 1www.tech.findforinfo.com."— Presentation transcript:

1 Validation and Rich controls 1www.tech.findforinfo.com

2 ► Calendar control  Formatting a calendar  Restricting dates 2www.tech.findforinfo.com

3 The Calendar Control ► It is one of the most impressive controls ► It is called as rich control because it can be generated with a simple tag but it is rendered in dozens of HTML lines 3www.tech.findforinfo.com

4 Calendar controls -Default features ► Calendar control presents a single month view (User navigates) ► Each time the page is posted back and ASP.NET provides a new page ► The date is selected and it can be retrieved ► The day is retrieved as DateTime Object from the Calendar.SelectedDate property 4www.tech.findforinfo.com

5 Basic set of features ► Configuration of selection modes ► Select entire month/week ► Done using the Calendar.SelectionMode property ► Static calendar 5www.tech.findforinfo.com

6 Calendar control properties PropertyDescription Caption Caption of the calendar CaptionAlign Alignment of the calendar CellPadding The space between the cell walls and the content Cellspacing Space between cells DayStyle The format for displaying days NextPrevFormat The format for next previous month links 6www.tech.findforinfo.com

7 Calendar control properties PropertyDescription SelectedDate The selected date SelectionMode How a user is allowed to select dates SelectorStyle The style for the month and week selection link ShowGridLines Boolean property ShowTitle OnDayRender The name of the function to be executed when when each day cell is created 7www.tech.findforinfo.com

8 Formatting the calendar control PropertyDescription Horizontal Align Sets the contents with the horizontal alignment Vertical Align Sets the contents with the vertical alignment Wrap Specifies whether the contents are to be wrapped automatically or the cell is to be extended 8www.tech.findforinfo.com

9 Formatting the calendar control PropertyDescription Horizontal Align Sets the contents with the horizontal alignment Vertical Align Sets the contents with the vertical alignment Wrap Specifies whether the contents are to be wrapped automatically or the cell is to be extended 9www.tech.findforinfo.com

10 Formatting the calendar control PropertyDescription DaysHeaderStyle The style for the days of the week DayStyle The default style for the dates NextPrev style The style for the navigation OtherMonthDaysStyle The style for the dates that are not currently displayed SelectedDayStyle The style for the selected day SelectorStyle The style for the selector controls 10www.tech.findforinfo.com

11 Adrotator ► The Adrotator displays a randomly selected image ► It contains the xml file that lists all the available images 11www.tech.findforinfo.com

12 Elements ElementDescription ImageUrl The url for the image relative url NavigateUrl The link that will be followed when the user clicks on the banner Alternatetext The text that will be displayed if the picture cannot be displayed Impression A number that set the appearance of the advertisement Keyword Used for filtering the advertisements 12www.tech.findforinfo.com

13 Property PropertyDescription Advertisement file Relative path Keyword filter To filter the file Target The target window or frame 13www.tech.findforinfo.com

14 Specific values for the target TargetDescription _blank The link opens a new unframed window _parent The link opens in the parent of the current frame _self The link opens in the current frame _top The link opens in the topmost frame of the current window 14www.tech.findforinfo.com

15 Validation controls ► Powerful tool to verify the user input and display custom error messages ► Five different validation controls inherited from the BaseValidator class 15www.tech.findforinfo.com

16 Why Validation ► User’s might ignore an important field and leave it blank ► Users might provide and invalid entry in to the input field ► Users might make a typing mistake(ie) a non-numeric value in the numeric field 16www.tech.findforinfo.com

17 Validation process ► The validator controls are used to verify a page automatically when the user submits it or manually in your code. ► The process  The user receives the input form and tries to fill up the input controls  When finished the user clicks the button to submit the page  Every button control has a CausesValidation property 17www.tech.findforinfo.com

18 CausesValidation property ► If this property is set to False,ASP.NET ignores the validation controls,the page will be posted back ► If this property is set to True,then the ASP.NET engine validates the page when the user clicks the button ► Each control is validated and if any controls fails to validate then the page is returned with some error 18www.tech.findforinfo.com

19 When does validation happen? ► It happens only when the button is click and not when the page is posted back 19www.tech.findforinfo.com

20 Validation classes ► System.Web.UI.WebControls namespace ► Validator controls are inherited from the BaseValidator class 20www.tech.findforinfo.com

21 Basic property PropertyDescription ControlToValidate Identifies the control to be validated ErrorMessageForecolorDisplay ErrorMessage is displayed when validation fails Display has two mode (Dynamic,Static) IsValid Returns true or false based on validation Enabled When set to false automatic validation will not take place 21www.tech.findforinfo.com

22 Validator Specific Properties PropertyDescription RequiredFieldValidator None required RangeValidatorMaximum,Minimum,Type CompareValidator ControlToCompare,Operator, Type RegularExpressionValidator Validation Expression CustomValidator ClientValidation Function ServerValidate event 22www.tech.findforinfo.com

23 Server-Side Validation ► ASP.NET adds a javascript and DHTML code ► Normally in all validation controls the error message will be displayed when the focus changes ► To check the server-side validation set the RangeValidator.EnableClientScript property to false ► In this case the error message will be displayed only the button is clicked and the page will be returned from the server 23www.tech.findforinfo.com

24 24www.tech.findforinfo.com

25 25www.tech.findforinfo.com

26 After setting the property to false 26www.tech.findforinfo.com

27 Other Display options ► Use the Validation Summary control ► The Range Validator Display property is set to None ► Set to display mode property to message box then the Error messages are displayed in a message box 27www.tech.findforinfo.com

28 28www.tech.findforinfo.com

29 29www.tech.findforinfo.com

30 Setting the property 30www.tech.findforinfo.com

31 Manual Validation ► There are three ways to create manual validation ► Use your own code to validate the controls ► Disable the EnableClientScript property for each validation control. ► Add a button with CauseValidation property set to false.When the page is clicked the validation is clicked 31www.tech.findforinfo.com

32 Compare Validator ► This control compares the values in one input control with the other ► The type of comparison depends on the operator property 32www.tech.findforinfo.com

33 Property PropertyDescription ControltoValidate Identifies the control to validate ErrorMessage If validation fails the validator control will display the message IsValid After validation is performed,this returns True or False based on the validation ControlToCompare The input control that contains the comparison value Operator Specifies the type of comparison =,>,<,>=,<=,<> 33www.tech.findforinfo.com

34 Property PropertyDescription Type The data type of the values that will be compared(String,Integer,double,Date,or currency) ValueToCompare Instead of ControlToCompare,If both are set then ControlTocompare takes precedence 34www.tech.findforinfo.com

35 Range Validator ► This control checks whether the given value in the input control falls within the range 35www.tech.findforinfo.com

36 Property PropertyDescription Type The data type of the values that will be compared(String,Integer,double,Date, or currency) Maximum Value The largest value Minimum Value The smallest value 36www.tech.findforinfo.com

37 RegularExpression validator ► This control checks whether the user entered value matches the specified the regular expression ► Propertydescription ValidationA string that expression contains ValidationA string that expression contains the expression the expression 37www.tech.findforinfo.com

38 Literals and Metacharacters ► All regular expressions are made up of two characters:Literals and Metacharacters ► In literals only the code is typed Search for the string literal I you will find the character I 38www.tech.findforinfo.com

39 Metacharacters ► Consider the following expression ► Del *.* ► The above expression consists of one literal (.) and two metacharacters(the asterisks) ► Translated as delete  Any file  With any number of characters  With an extension of any number of characters 39www.tech.findforinfo.com

40 Regular expression example ► \s denotes whitespace ► \d represents any digit ► Thus the following expression starts with any expression that starts with the number 333 followed by a single white space and any three digits ► 333\s\d\d\d 40www.tech.findforinfo.com

41 Delimiting range of characters ► Delimit by the square brackets ► [a-f] ► The above expression matches any word that starts with the letter from “a” to “f” lowercase 41www.tech.findforinfo.com

42 Some of the common regular expression characters CharacterDescription \s Any white space or tab \S Any non-white space character \d Any digit character \D Any character that is not a digit \w Any word character (letter,number,underscore) 42www.tech.findforinfo.com

43 Commonly Used Regular expression Content Regular expression Description Email address \S+@+\S+\.\S + Checks for symbol,non-white space character Password length \w{4,10} A password atleast four characters long and less than 10 characters Social security Number\d{3}-\d{2}-\d{4} A sequence of digits as follows 444-22-5555 43www.tech.findforinfo.com

44 RequiredFieldValidator ► This control checks whether the user has entered a value in the given control 44www.tech.findforinfo.com

45 Property PropertyDescription InitialValue The initial value of the input control and it is set to empty string 45www.tech.findforinfo.com

46 Custom Validator ► This control allows the user to enter their own validation algorithm ► Validation is performed to the server side by responding to the ServerValidate event 46www.tech.findforinfo.com

47 Property PropertyDescription clientValidation Function A string that contains the function name ServerValidate event The code responds to the event and the object Server-ValidateEvent Args is received that contains the user entered values and specifies whether the validation succeded or not 47www.tech.findforinfo.com

48 Validation Summary ► This control displays a summary of all error messages for every validation control 48www.tech.findforinfo.com

49 Property PropertyDescription DisplayMode Set the format for the validation summary text (List,SingleParagraph,BulletList) Headertext Sets the header to the control showMessageBox When set to true the validation summary will be displayed in a message box 49www.tech.findforinfo.com


Download ppt "Validation and Rich controls 1www.tech.findforinfo.com."

Similar presentations


Ads by Google