Thursday 16 February 2012

ASP.Net Controls and their Functionalities

Label:  Initializes a new instance of the Label class.  It is used to display text on a page.
Properties:
  1. Text:  Specifies the text to display
DropDownList:  It is used to create a dropdown list.  Each selectable item in a DropDownList control is defined by a ListItem element.  It will support data binding.
Properties:
  1. SelectedIndex:  Index of a selected item.
  2. SelectedIndexChanged:  Name of the function to be executed when the index of the selected item has changed.
Hyperlink:  It is used to create a hyperlink.
Properties:
  1. ImageUrl:  URL of the image to display for the link.
  2. NavigateUrl:  Target URL of the link.
  3. Target:  Target frame of the URL.
  4. Text:  Text to display for the link.
HiddenField:  Store information in the page without displaying it that needs to be persisted across multiple postbacks to the server.  The information in a HiddenField control is not displayed when the browser renders the page, but users can see the contents of the control by viewing the page’s source so not advisable to store sensitive data.
Properties:
  1. Value:  Gets or sets the value of the HiddenField.
Panel:  It is used as a container for other controls.
Properties:
  1. BackImageUrl:  Specifies a URL to an image file to display as a background for this control.
  2. DefaultButton:  Specifies the ID of the default button in the panel.
  3. Direction:  Specifies the content display direction of the panel.
  4. GroupingText:  Specifies the caption for the group of controls in the panel.
  5. HorizontalAlign:  Specifies the horizontal alignment of the content.
  6. ScrollBars:  Specifies the position and visibilty of scroll bars in the Panel.
  7. Wrap:  Specifies whether the content is wrap or not.
CheckBox:  It is used when you want to let the visitor select one or more options from a set of alternatives.
Properties:
  1. AutoPostBack:  Specifies whether the form should be posted immediately after the checked property has changed or not.  Default is false.
  2. CausesValidation:  Specifies if a page is validated when a button control is clikced.
  3. Checked:  Specifies whether the check box is checked or not.
  4. InputAttributes:  Attribute names and values for the input element for CheckBox control.
  5. LabelAttributes:  Attribute names and values for the label element for the CheckBox control.
  6. Text:  Text next to the checkbox.
  7. TextAlign:  On which side of the checkbox the text should appear.
  8. ValidationGroup:  Group of controls for which the Checkbox control causes validation when it posts back to the server.
RadioButton:  It allows the user to choose only one of a predefined set of options.
Properties:
  1. AutoPostBack:  A boolean value that specifies whether the form should be posted immediately after the checked property has changed or not.  Default is false.
  2. Checked:  A boolean value that specifies whether the radio button is checked or not.
  3. ID:  Uinque ID for the control.
  4. GroupName:  The name of the group to which this radio button belongs.
  5. Text:  Text next to the radio button.
  6. TextAlign:  On which side of the radio button the text should appear.
CheckBoxList:  It is used to create a multi-selection check box group.
Properties:
  1. CellPadding:  The amount of pixels between the border and the contents of the table cell.
  2. CellSpacing:  The amount of pixels between table cells.
  3. RepeatColumns:  The number of columns to use when displaying the checkbox group.
  4. RepeatDirection:  Specifies whether the check box group should be repeated horizontally or vertically.
  5. RepeatLayout:  The layout of the check box group.
  6. TextAlign:  On which side of the check box the text should appear.
Button:  The Button control is used to display a push button. The push button may be a submit button or a command button. By default, this control is a submit button.
A submit button does not have a command name and it posts the Web page back to the server when it is clicked. It is possible to write an event handler to control the actions performed when the submit button is clicked.
A command button has a command name and allows you to create multiple Button controls on a page. It is possible to write an event handler to control the actions performed when the command button is clicked.
Properties:
  1. CausesValidation:  Specifies if a page is validated when a button is clicked.
  2. CommandArgument:  Specifies additional information about the command to perform.
  3. CommandName:  Specifies the command associated with the Command event.
  4. OnClientClick:  Specifies the name of the function to be executed when a button is clicked.
  5. PostBackUrl:  Specifies the URL of the page to post to from the current page when a button is clicked.
  6. Text:  Specifies the text on a button.
  7. UseSubmitBehavior:  Specifies whether or not a button uses the browser's submit mechanism or the ASP.NET postback mechanism.
  8. ValidationGroup:  Specifies the group of controls a button causes validation, when it posts back to the server.
RadioButtonList:  It is used to create a group of radio buttons.
Properties:
  1. CellPadding:  The amount of pixels between the border and the contents of the table cell.
  2. CellSpacing:  The amount of pixels between table cells.
  3. RepeatColumns:  The number of columns to use when displaying the radio button group.
  4. RepeatDirection:  Specifies whether the radio button group should be repeated horizontally or vertically.
  5. RepeatLayout:  The layout of the radio button group.
  6. TextAlign:  On which side of the radio button the text should appear.
TreeView:  The TreeView Web server control is used to display hierarchical data, such as a table of contents or file directory, in a tree structure.
Features:
1.      Automatic data binding, which allows the nodes of the control to be bound to hierarchical data, such as an XML document.
2.      Site navigation support through integration with the SiteMapDataSource control.
3.      Node text that can be displayed as either selectable text or hyperlinks.
4.      Customizable appearance through themes, user-defined images, and styles.
5.      Programmatic access to the TreeView object model, which allows you to dynamically create trees, populate nodes, set properties, and so on.
6.      Node population through client-side callbacks to the server (on supported browsers).
7.      The ability to display a check box next to each node.
Root:  A node that has no parent node and one or more child nodes.
Parent:  A node that has a parent node and one or more child nodes.
Leaf:  A node that has no child nodes.

Expand/Collapse image:  An optional image that indicates whether the node can be expanded to show child nodes. By default, this is a plus sign [+] if the node can be expanded, or a minus sign [-] if the node can be collapsed.
Check box:  Check boxes can be optionally enabled, which allows users to select a particular node.
Node image:  You can specify a node image to display next to the node text.
Node text:  Node text is the actual text that displays on the TreeNode object.  Node text can behave like a hyperlink in navigation mode, or like a button in selection mode.

Properties:
1.      NodeSpacing:  Specifies the amount of vertical spacing between the entire current node and adjacent nodes above and below.
2.      VerticalPadding:  Specifies the amount of space rendered on the top and bottom of the TreeNode text.
3.      HorizontalPadding:  Specifies the amount of space rendered on the left and right of the TreeNode text.
4.      ChildNodesPadding:  Specifies the amount of space above and below the child nodes of the TreeNode.
  1. ImageUrl:  Specifies the path to the image that displays next to the TreeNode.
DIV:  It is a division or a section in an HTML document.  It is often used to group block of elements to format them with styles.
Event Attributes:
Onclick:  Script to be run on a mouse click
Ondblclick:  Script to be run on a mouse double-click
Onmousedown:  Script to be run when mouse button is pressed
Onmousemove:  Script to be run when mouse pointer moves
Onmouseout:  Script to be run when mouse pointer moves out of an element
Onmouseover:  Script to be run when mouse pointer moves over an element
Onmouseup:  Script to be run when mouse button is released
Onkeydown:  Script to be run when a key is pressed
Onkeypress:  Script to be run when a key is pressed and released
Onkeyup:  Script to be run when a key is released

Literal:  It is used to display text on a page.  It does not let you apply styles to its content.
Properties:
  1. Text:  Specifies the text to display
GridView:  It is a successor to the ASP.NET DataGrid control.  It provides more flexibility in displaying and working with data from your database in comparison with any other controls.  The GridView control enables you to connect to a datasource and display data is tabular format, however you have bunch of options to customize the look and feel.

Behavior Properties of the GridView Control
AllowPaging:  true/false. Indicate whether the control should support paging.
AllowSorting:  true/false. Indicate whether the control should support sorting.
SortExpression:  Gets the current sort expression (field name) that determines the order of the row.
SortDirection:  Gets the sorting direction of the column sorted currently (Ascending/Descending).
DataSource:  Gets or sets the data source object that contains the data to populate the control.
DataSourceID:  Indicate the bound data source control to use (Generally used when we are using SqlDataSource or AccessDataSource to bind the data, See 1st Grid example).
AutoGenerateEditButton:  true/false. Indicates whether a separate column should be added to edit the record.
AutoGenerateDeleteButton:  true/false. Indicates whether a separate column should be added to delete the record.
AutoGenerateSelectButton:  true/false. Indicate whether a separate column should be added to selecat a particular record.
AutoGenerateColumns:  true/false. Indicate whether columns are automatically created for each field of the data source. The default is true.

Style Properties of the GridView Control
AlternatingRowStyle:  Defines the style properties for every alternate row in the GridView.
EditRowStyle:  Defines the style properties for the row in EditView (When you click Edit button for a row, the row will appear in this style).
RowStyle:  Defines the style properties of the rows of the GridView.
PagerStyle:  Defines the style properties of Pager of the GridView. (If AllowPaging=true, the page number row appears in this style)
EmptyDataRowStyle:  Defines the style properties of the empty row, which appears if there is no records in the data source.
HeaderStyle:  Defines the style properties of the header of the GridView. (The column header appears in this style.)
FooterStyle:  Defines the style properties of the footer of GridView.

Appearance Properties of the GridView Control
CellPadding:  Indicates the space in pixel between the cells and the border of the GridView.
CellSpacing:  Indicates the space in pixel between cells.
GridLines:  Both/Horizontal/Vertical/None. Indicates whether GrdiLines should appear or not, if yes Horizontal, Vertical or Both.
HorizontalAlign:  Indicates the horizontal align of the GridView.
EmptyDataText:  Indicates the text to appear when there is no record in the data source.
ShowFooter:  Indicates whether the footer should appear or not.
ShowHeader:  Indicates whether the header should appear or not. (The column name of the GridView)
BackImageUrl:  Indicates the location of the image that should display as a background of the GridView.
Caption:  Gets or sets the caption of the GridView.
CaptionAlign:  left/center/right. Gets or sets the horizontal position of the GridView caption.

State Properties of GridView Control
Columns:  Gets the collection of objects that represent the columns in the GridView.
EditIndex:  Gets or sets the 0-based index that identifies the row currently to be edited.
FooterRow:  Returns a GridViewRow object that represents the footer of the GridView.
HeaderRow:  Returns a GridViewRow object that represents the header of the GridView.
PageCount:  Gets the number of the pages required to display the reocrds of the data source.
PageIndex:  Gets or sets the 0-based page index.
PageIndex:  Gets or sets the number of records to display in one page of GridView.
Rows:  Gets a collection of GridViewRow objects that represents the currently displayed rows in the GridView.
DataKeyNames:  Gets an array that contains the names of the primary key field of the currently displayed rows in the GridView.
DataKeys:  Gets a collection of DataKey objects that represent the value of the primary key fields set in DataKeyNames property of the GridView.

Events associated with GridView Control
PageIndexChanging, PageIndexChanged:  Both events occur when the page link is clicked. They fire before and after GridView handles the paging operation respectively.
RowCancelingEdit:  Fires when Cancel button is clicked in Edit mode of GridView.
RowCommand:  Fires when a button is clicked on any row of GridView.
RowCreated:  Fires when a new row is created in GridView.
RowDataBound:  Fires when row is bound to the data in GridView.
RowDeleting,RowDeleted:  Both events fires when Delete button of a row is clicked. They fire before and after GridView handles deleting operaton of the row respectively.
RowEditing:  Fires when a Edit button of a row is clicked but before the GridView hanldes the Edit operation.
RowUpdating, RowUpdated:  Both events fire when a update button of a row is clicked. They fire before and after GridView control update operation respectively.
Sorting, Sorted:  Both events fire when column header link is clicked. They fire before and after the GridView handler the Sort operation respectively.

ReportViewer:  ReportViewer is an ASP.NET server control developed using Visual Studio .NET.  The server control is based on a real-world scenario, and it demonstrates how to develop a custom control that you can use to integrate Reporting Services reports in a Web application.  ReportViewer server control uses Reporting Services URL access functionality to render and navigate reports in a Web browser.
Benefits:
  • Processes data efficiently. The reporting engine built into ReportViewer can perform operations such as filtering, sorting, grouping and aggregation.
  • Supports a variety of ways in which to present data. You can present data as lists, tables, charts and matrices (also known as crosstabs.)
  • Adds visual appeal. You can specify fonts, colors, border styles, background images etc to make your report visually appealing.
  • Enables interactivity in reports. You can have collapsible sections, document map, bookmarks, interactive sorting etc in your report.
  • Supports conditional formatting. You can embed expressions in the report to change display style dynamically based on data values.
  • Supports printing and print preview.
  • Supports export to Excel, Word and PDF formats.
Repeater:  It is used to display a repeated list of items that are bound to the control.  The Repeater control may be bound to a database table, an XML file, or another list of items.
Properties:
  1. ClientID:  Gets the control ID for HTML markup that is generated by ASP.NET.
  2. Controls:  Gets a System.Web.UI.ControlCollection that contains the child controls of the Repeatercontrol.
  3. DataMember:  Gets or sets the specific table in the DataSource to bind to the control.
  4. DataSource:  Gets or sets the data source that provides data for populating the list.
  5. DataSourceID:  Gets or sets the ID property of the data source control that the Repeater control should use to retrieve its data source.
  6. EnableTheming:  Gets or sets a value indicating whether themes are applied to this control.
  7. EnableViewState:  Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.
  8. FooterTemplate:  Gets or sets the System.Web.UI.ITemplate that defines how the footer section of theRepeater control is displayed.
  9. HeaderTemplate:  Gets or sets the System.Web.UI.ITemplate that defines how the header section of the Repeater control is displayed.
  10. ID:  Gets or sets the programmatic identifier assigned to the server control.
  11. UniqueID:  Gets the unique, hierarchically qualified identifier for the server control.
  12. ViewState:  Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

1 comment: