ASP.NET (2) - ASP.NET Controls

This series of articles is about ASP.NET. They are from my previous years, legacy notes on OneNote. Reviewing the concepts may be helpful even for our current programming because they have a lot of similar features, such as Angular, React, and these modern "laguanges".

A. Introduction

This article will be an ASP.NET Control Summary. I will just follow the exiting note without editing. It is quite informative.

  • A - Introduction
  • B - ASP.NET Controls
  • C. ASP.NET Controls Features

B. ASP.NET Controls

  1. Validation controls: (ASP.NET 3.5, p144)
    1. RequiredFieldValidator,
    2. RangeValidator,
    3. CompareValidator,
    4. RegularExpressionValidator,
    5. CustomValidator,
    6. ValidationSummary
  2. Send Code to Client Side
    • RegisterClientScriptBlock: emits just after the opening tag of the Page object's
    • RegisterStartupScript: emits just before the closing tag of the Page object
  3. ADO.NET
    • SqlConnection class
    • SqlCommand class (SqpParameter class)
    • SqlCommandBuilder class
    • SqlDataReader class
    • SqlDataAdapter class
    • SqlTransaction class
    • Note. Using Data Designer could build a Typed reference to an object from the database
    • DataSet: Read/Write; multiple tables from different databases; Disconnected;
      • Forward/backward; slower access; supported by VS.NET tools; Bind to multiple controls
      • DataView: Represents a databindable, customized view of a DataTable for sorting, filtering, searching, editing, and navigation.
      • DataRelation: Represents a parent/child relationship between two                    
        • DataTable objects
        • DeleteRule of ForeignKeyConstrint:
          • Cascade (default), None, SetDefault, SetNull
      • DataTable: Represents one table of in-memory data.
      • DataRow: Represents a row of data in a DataTable.
    • DataReader: Read-only; based on SQL from one database; Connected; Forward Only; faster access; manually coded; Bind to one control
  4. ADO Objects
    • Connection, Errors - Error
    • Command, Parameters – Parameter
    • Recordset
      • CurserType:
        • ForwardOnly,
        • Static,
        • KeySet,
        • Dynamic
      • LockType:
        • ReadOnly,
        • Pessimistic (lock upon editing),
        • Optimistic (lock  upon updating),
        • BatchOptimistic
  5. get a DataSet
    • Create a Connection
    • Create a DataAdapter
    • Create a DataSet
      • (Create a DataView for sorting, filtering, searching, editing, and navigation)
    • Bind both the DataSet and DataView to DataGrid controls
  6. Use a DataReader
    • Create a Connection
    • Create a Command
    • Create a DataReader from the Command by Call ExecuteReader method
    • Call Read for each record …
  7. List-bound controls
    • DropDownList
    • ListBox
    • Table
    • DataGrid
    • DataList
    • Repeater: the simplest List Bond control to support templet

C. ASP.NET Controls Features

  • Use DropDownList, ListBox, and Table for simple dynamic tables or lists;
  • Use DataGrid, DataList, and Repeater for complex tables or lists
  • Readonly: ListBox and DropDownList
  • Adding items at design time by Item collection editor box for ListBox, DropDownList, and Table
    • DataBinding: Use <%# … %>  only used to bind a single property, such as txt, ForeColor, and BackColor.  This is the only binding mode supported by simple controls like TextBox, Label, Literal, CheckBox, and RadioButton, but can be used with single-value properties of any controls (for example, the ForeColor property of a DataGrid control). Text='<%# Titles("price") %>' Text='<%#DataBinder.Eval(Titles, "(""price"")", "{0:C4}") %>'
    • DataSource for DataBinding: any public data (Web Dev. P 147)
      • Database Table
      • An array
      • A property of an object
      • An expression combining several items
    • Template Controls: Repeater, DataList and DataGrid
      • This can be filled by only using Data Binding (no static assignment)
      • Template: a container for HTML code
        1. HeaderTemplate (All)
        2. ItemTemplate (all)
        3. AlternatingItemTemplate (Repeater and DataList)
        4. SeparatorTemplate (Repeater and DataList)
        5. SelectedItemTemplate (DataList)
        6. EditItemTemplate (DataList and DataGrid)
        7. FooterTemplate (all)
        8. PagerTemplate (DataGrid)
      • Template control events:
        • For all
          • ItemCreated (all)
          • ItemDataBound (all)
          • ItemCommand click (all)
        • For DataList and DataGrid
          • SelectedIndexChanged – CommanNema=Select
          • EditCommand – CommanNema=Edit
          • UpdateCommand – CommanNema=Update
          • CancelCommand – CommanNema=Cancel
          • DeleteCommand – CommanNema=Delete
        • For DataGrid
        • SorCommand – AllowSorting=true
        • PageIndexChanged – AllowPaging=true
      • Repeater:
        • Doesn’t support the design time editing tool
        • Support Items of Template:
          • ​​​​​​​ HeaderTemplate
          • ItemTemplate
          • AlternatingItemTemplate
          • SeparatorTemplate
          • FooterTemplate
      • ​​​​​​​DataList:
        • Support design time editing tool
          • Auto Format
          • Property Builder
          • Edit Template
        • ​​​​​​​Support Items of Template as Repeater as, plus
          • ​​​​​​​SelectedItemTemplate
          • EditItemTemplate
      • ​​​​​​​DataGrid:
        • Support design time editing tool, as DataList
        • Support Columns:
          • ​​​​​​​Bound Columns
          • Button Columns
            • Select
            • Edit,
            • Update,
            • Cancel
            • Delete
          • HyperLink Column
          • Template Column
        • Support Items in Template Column
          • ​​​​​​​HeaderTemplate
          • ItemTemplate
          • EditItemTemplate
          • FooterTemplate
        • ​​​​​​​Support PagerTemplate


Similar Articles