Web Server Controls - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Web Server Controls

Description:

Using PlaceHolder control can help dynamically build forms ... CustomValidator Evaluates data against custom criteria. Common Validation Control Properties ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 13
Provided by: Chan138
Category:

less

Transcript and Presenter's Notes

Title: Web Server Controls


1
Web Server Controls
  • Lab4 Web Server Controls

2
ASP.Net WebForm Controls
  • Most ASP.Net 3.5 Web Server controls are located
    on the Standard tab in the toolbox.
  • The ASP.Net Webforms inherit from the Web Control
    class which is found in the System.Web.UI.WebContr
    ols namespace.
  • Label (label1.Text)
  • TextBox (TextBox1.Text)
  • Image / ImageButton (imageUrl)
  • Button (click)
  • Dropdown List (dropdownList1.SelectedValue)
  • ListBox
  • Checkbox / CheckBoxList
  • Radiobutton / RadioButtonList
  • Calendar
  • FileUpLoad
  • Panel
  • PlaceHolder

3
Panel Control
  • The Panel control is used as a container for
    other controls. It serves several functions-
    To control the visibility of the control it
    contains- To control the appearance of the
    controls it contains- To make it easier to
    generate controls programmatically.

4
PlaceHolder Control
  • The PlaceHolder Web server control holds a spot
    for you to programmatically add or remove
    controls in its place. Using PlaceHolder control
    can help dynamically build forms and customize
    the users interface.
  • The PlaceHolder control doesnt produce any
    visible output without the use of other controls.

5
Using Validation Controls
  • The five validation controls are
  • RequiredFieldValidator Makes sure a form field
    is not left blank
  • RangeValidator Makes sure a fields value falls
    between a given range
  • CompareValidator Compares a fields value with
    other values or other fields values
  • RegularExpressionValidator Evaluates data
    against a regular expression
  • CustomValidator Evaluates data against custom
    criteria

6
Common Validation Control Properties
  • ControlToValidate Name of the control to check
  • ErrorMessage -- text to be displayed if invalid
  • Text text to be displayed if the data is
    invalid
  • Display
  • Static
  • Dynamic
  • None
  • SetFocusOnError set focus to control if invalid

7
Specialized Properties
  • RequiredFieldValidator
  • InitialValue invalid if control matches
    InitialValue (defaults to nothing)
  • CompareValidator
  • Opeartor type of comparison
  • ValueToCompare value to test against
  • ControlToCompare name of control to test against
  • RangeValidator
  • MinimumValue
  • MaximumValue
  • Type
  • RegularExpression
  • ValidationExpression format

8
Validator Examples
  • Validator settings User Entry
    Result?
  • RequiredField
  • InitialValue
  • InitialValue Enter Name
  • CompareValidator
  • ValueToCompare Pat Operator Equal
    Type String
  • ValueToCompare Pat Operator Equal
    Type String Operator DataTypeCheck Type
    Currency

Valid?
Enter Name
Valid?
Valid?
Valid?
pat
Pat
Valid?
9
Validator Examples (cont.)
  • Validator settings User Entry
    Result?
  • RangeValidator
  • MaximumValue20
  • MinimumValue 2 Type String
  • MaximumValue20
  • MinimumValue 2 Type Integer
  • MaximumValueThompson
  • MinimumValue Fred Type String
  • RegularExpressionValidator ValidationExpression
    A-Z\dA-Z\ \dA-Z\d

15
Valid?
Valid?
15
Valid?
Terry
N7A 2L3
Valid?
10
ValidationSummary Control
  • To summarize the error messages from all
    validators on a Web page, in one location
  • DisplayMode displays as a list (List), a
    bulleted list (BulletList), or a single paragraph
    (SingleParagraph)
  • ShowSummary - shows the entire list of error
    messages from invalid controls
  • ShowMessageBox - displays an additional message
    in an alert box by setting
  • HeaderText - allows you to display a heading
    message

11
Extending Validation
  • ValidationGroup property -- Validators and
    Buttons
  • CausesValidation property any control that can
    submit a page
  • Checking that validation succeeded Page--
    IsValid

12
Lab 4 Exercises
Write a Comment
User Comments (0)
About PowerShow.com