.NET Samples - ASP.NET Server Control Reference

This section includes the following samples:

Xml2 Sample

DataGrid8 Sample

DataGrid1 Sample

DataGrid9 Sample

DataGrid6 Sample

DataGrid3 Sample

DataGrid7 Sample

DataGrid5 Sample

DataGrid4 Sample

DataGrid13 Sample

DataList2 Sample

DataList3 Sample

DataGrid2 Sample

DataList1 Sample

DataGrid11 Sample

DataGrid12 Sample

DataGrid10 Sample

HtmlAnchor2 Sample

HyperLink2 Sample

Label1 Sample

PlaceHolder1 Sample

AdRotator1 Sample

HtmlInputCheckBox1 Sample

HtmlForm1 Sample

HtmlButton1 Sample

HtmlInputButton2 Sample

ImageButton3 Sample

Button1 Sample

Button3 Sample

LinkButton1 Sample

RadioButtonList1 Sample

HtmlInputRadioButton1 Sample

Calendar1 Sample

Calendar2 Sample

HtmlGenericControl1 Sample

HtmlInputButton1 Sample

HtmlInputText1 Sample

HtmlSelect1 Sample

HtmlInputFile1 Sample

CustomValidator1 Sample

RangeValidator1 Sample

RadioButton1 Sample

HtmlTextArea1 Sample

HyperLink1 Sample

ImageButton1 Sample

HtmlInputImage1 Sample

HtmlImage1 Sample

CheckBox1 Sample

DropDownList2 Sample

ImageButton2 Sample

TextBox1 Sample

ListBox2 Sample

CompareValidator1 Sample

CheckBoxList1 Sample

Image1 Sample

DropDownList1 Sample

ListBox1 Sample

Panel1 Sample

ValidationSummary1 Sample

Table1 Sample

HtmlSelect2 Sample

HtmlInputHidden1 Sample

HtmlAnchor1 Sample

RegularExValidator1 Sample

Button2 Sample

Repeater1 Sample

ReqFieldValidator1 Sample

Calendar5 Sample

Calendar3 Sample

Calendar4 Sample

HtmlTable1 Sample

Xml1 Sample

Xml2 Sample

This sample demonstrates creating custom XmlDocument and XslTransform objects and passing them into the Xml server control to be displayed. You can also pass a preloaded XmlDocument to the Xml server control's Document property. Additionally, you can pass a preloaded XslTransform to the control's Transform property.

Namespaces used in this sample:

System; System.Xml; System.Xml.Xsl

Classes used in this sample:

Xml; XmlDocument; Page; XslTransform; Import; Path; EventArgs; Object

DataGrid8 Sample

This sample shows how to implement simple sorting in DataGrid.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; DataColumn; DataView; Font; String; DataTable; Object; Header; Style; Table; EventArgs; Page; CommandEventArgs; DataRow; Import; DataGridSortCommandEventArgs

DataGrid1 Sample

This sample demonstrates using the DataGrid server control to display tabular data and optionally support selecting, sorting, paging, and editing the data. By default, DataGrid generates a BoundColumn for each field in the data source; the AutoGenerateColumns property is set to true.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; DataColumn; Font; DataTable; Table; DataView; String; Style; DataRow; Page; Header; EventArgs; Import; Object

DataGrid9 Sample

This sample creates an Outlook-style sort button using a TemplateColumn. Note that the button must also specify the "sort" CommandName. Additionally, it must pass the field by which to sort as a CommandArgument.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; Header; DataColumn; String; Button; Font; DataView; Table; DataTable; Image; Object; Style; TemplateColumn; BoundColumn; EventArgs; Page; CommandEventArgs; Label; Import; DataBinder; DataGridSortCommandEventArgs; Binder; Url; ImageButton; Container; DataRow

DataGrid6 Sample

This sample demonstrates using the EditCommandColumn. The EditCommandColumn is a special column type that supports in-place editing of the data in one row in the grid. EditCommandColumn interacts with another property of the grid, EditItemIndex. By default, the value of EditItemIndex is -1, meaning none of the rows (items) in the grid is being edited. If EditItemIndex is -1, an Edit button is displayed in the EditCommandColumn for each row in the grid.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; Header; Table; Object; DataTable; EventArgs; String; CommandEventArgs; Style; DataGridCommandEventArgs; DataColumn; BoundColumn; Font; TextBox; DataView; DataRow; Control; Page; Import; EditCommandColumn

DataGrid3 Sample

This sample demonstrates passing the value of the IntegerValue data field as an argument in the URL to another page. The StringValue data field is used as the display text of the hyperlink. A HyperLinkColumn presents the bound data in HyperLink controls. This is typically used to navigate from an item in the grid to a details view on another page.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; String; Header; DataColumn; BoundColumn; Form; DataTable; HyperLink; Object; Style; Font; EventArgs; Page; DataView; HyperLinkColumn; Url; Table; Import; DataRow

DataGrid7 Sample

This sample demonstrates using the grid column Visible property.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; String; Header; DataColumn; BoundColumn; Label; Button; Object; Style; Font; EventArgs; DataTable; DataView; Table; Import; Page; DataRow; Form

DataGrid5 Sample

This sample demonstrates using two TemplateColumns. With a TemplateColumn you completely control which controls are rendered in the column, and which data fields are bound to the controls. The first column renders two LinkButton controls. These bubble commands to the grid's ItemCommand, just as a ButtonColumn does. The last column binds the true or false value to a read-only CheckBox.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; Table; DataColumn; Header; Button; DataTable; Font; TemplateColumn; String; DataView; Style; TableCell; LinkButton; EventArgs; BoundColumn; DataRow; CommandEventArgs; Object; Import; DataBinder; Page; Binder; Form; Container; DataGridCommandEventArgs; Assembly; CheckBox

DataGrid4 Sample

This sample shows how a ButtonColumn is used to bubble a user command from within a row to an event handler on the grid. In this sample, the "Add To Cart" and "Remove From Cart" commands cause the item from the corresponding row to be added to or removed from a simple shopping cart.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; Table; DataColumn; Header; DataTable; Button; Font; DataView; String; Style; TableCell; ButtonColumn; BoundColumn; Object; DataRow; EventArgs; Import; Page; CommandEventArgs; Form; LinkButton; DataGridCommandEventArgs; Assembly

DataGrid13 Sample

This sample demonstrates using TemplateColumns to precisely control how the data is edited.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataGrid; TemplateColumn; Header; CheckBox; TextBox; DataRow; Font; DataTable; String; DataColumn; Container; Table; Page; Object; GC; EventArgs; Form; DataRowView; Label; Control; BoundColumn; Style; DataView; LinkButton; Button; Binder; GridItem; DataGridItem; Import; DataBinder

DataList2 Sample

This sample illustrates using a SelectedItemTemplate property in a DataList to customize the content and appearance of the selected item. The SelectedItemTemplate is controlled by the SelectedIndex property. By default the value of SelectedIndex is -1, meaning none of the items in the list is selected. When SelectedIndex is set to a particular item, that item is displayed using the SelectedItemTemplate.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataList; String; DataBinder; Binder; Container; Header; Style; DataColumn; Button; Font; EventArgs; DataTable; DataView; LinkButton; Table; DataListCommandEventArgs; Page; DataRow; Object; CommandEventArgs; Import

DataList3 Sample

This sample illustrates editing items in DataList. The DataList control supports in-place editing of the data in an item through its EditItemTemplate property. The EditItemTemplate property defines the content and appearance of the item when it is being edited.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

DataList; TextBox; Binder; Label; Object; DataTable; EventArgs; DataBinder; Container; Table; Style; DataColumn; Button; CommandEventArgs; String; LinkButton; DataListCommandEventArgs; Header; Control; DataView; DataRow; Font; Import; Page

DataGrid2 Sample

This sample shows how to use BoundColumn. By explicitly creating a BoundColumn in the grid's Columns collection, you can control the order and rendering of each column.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

Header; DataGrid; BoundColumn; String; DataColumn; Font; Page; DataTable; Style; DataView; Table; Debug; EventArgs; Import; Form; DataRow; Object

DataList1 Sample

This sample illustrates using a simple DataList control. The DataList server control displays data items in a repeating list, and optionally supports selecting and editing the items. The content and layout of list items in DataList is defined using templates. At a minimum, every DataList must define an ItemTemplate; however, several optional templates can also be used to customize the appearance of the list.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

ListItem; DataList; DropDownList; Table; Button; String; Header; Font; Object; EventArgs; DataTable; DataView; Style; Page; Import; DataBinder; DataRow; Binder; LinkButton; Container; DataColumn; CheckBox

DataGrid11 Sample

This sample demonstrates how to hide the built-in pager user interface and supply your own paging UI. The DataGrid built-in page navigation controls, called the "pager," displays either as "next/previous" buttons or as a set of numeric page buttons.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

Page; DataGrid; Font; Button; Style; LinkButton; String; DataColumn; Object; EventArgs; DataTable; DataView; Label; Table; DataRow; Convert; Header; DataGridPageChangedEventArgs; Import

DataGrid12 Sample

This sample demonstrates using the DataGrid to work with large amounts of data. For very large data models, it is expensive to load the entire data source each time the grid is paged. A common alternative is to retrieve the data in page-size "chunks," rather than retrieving all the data and then stepping into the current row.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

Page; DataGrid; Label; Style; DataColumn; String; DataTable; Object; Table; DataView; EventArgs; Font; DataRow; DataGridPageChangedEventArgs; Import; Header

DataGrid10 Sample

This sample shows how to enable paging in DataGrid by setting the AllowPaging property to true. When enabled, the grid displays page navigation buttons either as "next/previous" buttons or as numeric buttons. When a page navigation button is clicked, the PageIndexChanged event is thrown. You must handle this event in your code. The most basic logic assigns the CurrentPageIndex to the event argument's NewPageIndex property and then rebinds the data source, as in this sample.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

Page; DataGrid; Style; DataColumn; Font; String; DataTable; Object; Table; Label; EventArgs; DataView; Header; DataGridPageChangedEventArgs; Import; DataRow

HtmlAnchor2 Sample

This sample shows how the HtmlAnchor control supports data binding to its HRef and InnerHtml properties.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

Repeater; String; DataColumn; Page; DataTable; Object; HtmlAnchor; Binder; EventArgs; DataBinder; Container; Table; DataRow; DataView; Import; Binding; DataBinding

HyperLink2 Sample

This sample illustrates binding data to a HyperLink control. The HyperLink control supports binding data to its Text and NavigateURL properties.

Namespaces used in this sample:

System.Data; System

Classes used in this sample:

Repeater; String; DataColumn; Page; HyperLink; DataTable; Object; Table; Binder; EventArgs; DataBinder; Container; DataRow; DataBinding; DataView; Url; Import; Binding; HtmlAnchor

Label1 Sample

This sample illustrates using the Label control. The Label server control displays text in a set location on the page. Unlike static text, the Text property of a label can be set programmatically.

Namespaces used in this sample:

System.Web; System

Classes used in this sample:

Label; Button; Font; Object; Style; TextBox; HttpUtility; EventArgs

PlaceHolder1 Sample

This sample illustrates adding controls to a PlaceHolder. The PlaceHolder server control can be used as a container control within a document to dynamically load other controls. The PlaceHolder control has no HTML-based output and is only used to mark a location for other controls that can be added to the Controls collection of the PlaceHolder during page execution.

Namespaces used in this sample:

System.Web; System.Web.UI.HtmlControls; System; System.Web.UI

Classes used in this sample:

Button; Control; HtmlButton; PlaceHolder; Page; HtmlControl; Object; EventArgs; Import

AdRotator1 Sample

This sample illustrates using the AdRotator control. The AdRotator server control presents ad images that, when clicked, navigate to a new Web location. Each time the page is loaded into the browser, an ad is randomly selected from a predefined list.

Namespaces used in this sample:

(none)

Classes used in this sample:

AdRotator; File

HtmlInputCheckBox1 Sample

This sample demonstrates using the HtmlInputCheckBox control. The HtmlInputCheckBox control accepts Boolean (true or false) input. When selected, its Checked property is set to true.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; CheckBox; HtmlInputCheckBox; EventArgs

HtmlForm1 Sample

This sample shows how an HtmlForm control is required to process post-back requests. A Web Forms page might only have one server-side <form> tag; however, client forms (without a runat=server attribute) can also post information back to server-side logic as long as a server-side form is present on the page.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; EventArgs; Form; HtmlForm

HtmlButton1 Sample

This sample demonstrates using the HtmlButton control. The HtmlButton control renders as an HTML 4.0 <button>. This differs from <input type="button"> in that it enables Web developers to create rich user interface form buttons that can be composed from embedded HTML elements (and even other ASP.NET server controls).

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; EventArgs; HtmlButton

HtmlInputButton2 Sample

This sample demonstrates using the HtmlInputButton control. The HtmlInputButton control also supports the Reset and Submit button types, which are used only with forms. Submit submits the form, whereas Reset restores all the entry fields in a form to their initial values.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; HtmlInputButton; EventArgs

ImageButton3 Sample

This sample shows how you can hook the client script events onmouseover and onmouseout to an ImageButton control to provide mouse-over effects such as changing the image source of the button. Client attributes such as onmouseover are disregarded by ASP.NET on the server, and passed "as is" to the browser. If your application targets newer browsers that support DHTML, these events occur in the browser as the pointer passes over the button.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; Image; Label; ImageButton; Url; ImageClickEventArgs; EventArgs

Button1 Sample

This sample illustrates using a simple Button control. The Button server control provides a push button-style control that is used to post a Web Form back to the server.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; Label; EventArgs

Button3 Sample

This sample shows how you can hook the client script events onmouseover and onmouseout to a Button control to provide mouse-over effects such as changing the font or color of the button. Client attributes such as onmouseover are disregarded by ASP.NET on the server, and passed "as is" to the browser. If your application targets newer browsers that support DHTML, these events will occur in the browser as the pointer passes over the button.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; Label; EventArgs

LinkButton1 Sample

This sample demonstrates using the LinkButton to post a Web Form back to the server. For additional button examples, see Button and ImageButton. For a control that navigates to another page, see HyperLink.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; LinkButton; Label; Font; Object; EventArgs

RadioButtonList1 Sample

This sample illustrates using the RadioButtonList control. The RadioButtonList server control provides a single-selection checked list. Like other list controls, RadioButtonList has an Items collection with members that correspond to each item in the list. To determine which items are selected, test the Selected property of each item.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; ListItem; RadioButtonList; RadioButton; Label; EventArgs; Object; CheckBox; Table

HtmlInputRadioButton1 Sample

This sample shows how an HtmlInputRadioButton control creates a single radio button input field. Setting the Name attribute the same way on each radio button forms a group in which only one radio button can be selected at a time. The selected state must be tested on the individual radio buttons, however.

Namespaces used in this sample:

(none)

Classes used in this sample:

Button; RadioButton; EventArgs; HtmlInputRadioButton

Calendar1 Sample

This sample illustrates using a simple Calendar control. The Calendar server control displays a month calendar from which users can select dates.

Namespaces used in this sample:

(none)

Classes used in this sample:

Calendar; Label; EventArgs; String

Calendar2 Sample

This sample illustrates the four Calendar date selection modes.

Namespaces used in this sample:

(none)

Classes used in this sample:

Calendar; Style; ListItem; Label; Font; String; DropDownList; EventArgs; Header; Object; Page

HtmlGenericControl1 Sample

This sample demonstrates using the HtmlGenericControl. The HtmlGenericControl provides an ASP.NET server control implementation for all unknown HTML server control tags not directly represented by a specific HTML server control.

Namespaces used in this sample:

(none)

Classes used in this sample:

Control; HtmlGenericControl; EventArgs; Attribute

HtmlInputButton1 Sample

This sample demonstrates using the HtmlInputButton control. The HtmlInputButton control (<input type=button>) is similar in function to the <button> tag, except that it can target any browser.

Namespaces used in this sample:

(none)

Classes used in this sample:

EventArgs; Button; HtmlInputButton

HtmlInputText1 Sample

This sample demonstrates using the HtmlInputText control. The HtmlInputText control is a single-line input control that lets the user enter text. HtmlInputText supports two behaviors. If the Type property is set to Text, HtmlInputText operates as a standard text box. If Type is set to Password, the user's input is masked by the "*" character to keep it private.

Namespaces used in this sample:

(none)

Classes used in this sample:

EventArgs; HtmlInputText

HtmlSelect1 Sample

This sample illustrates using the HtmlSelect control. The HtmlSelect control provides a drop-down list.

Namespaces used in this sample:

(none)

Classes used in this sample:

EventArgs; HtmlSelect; Style

HtmlInputFile1 Sample

This sample shows how an HtmlInputFile control handles uploading of binary or text files from a client browser to the server. File upload works with all HTML 3.2 and later Web clients. Note that the Enctype attribute on the <form> tag must be set to "multipart/form-data".

Namespaces used in this sample:

(none)

Classes used in this sample:

File; Button; HtmlInputFile; Exception; EventArgs; String

CustomValidator1 Sample

This sample demonstrates using the CustomValidator server control to call a user-defined function to perform validations that the standard validators can't handle. The custom function can execute on the server or in client-side script, such as JScript or VBScript.

Namespaces used in this sample:

(none)

Classes used in this sample:

Font; CustomValidator; Page; EventArgs; TextBox; ServerValidateEventArgs; Label; Control; Button; Exception

RangeValidator1 Sample

This sample illustrates using the RangeValidator control. The RangeValidator server control tests whether an input value falls within a given range. RangeValidator uses three key properties to perform its validation. ControlToValidate contains the value to validate. MinimumValue and MaximumValue define the minimum and maximum values of the valid range. These constants are stored as string values, but converted to the data type defined by Type when the comparison is performed.

Namespaces used in this sample:

(none)

Classes used in this sample:

Font; Type; String; Button; RangeValidator; Page; Label; TextBox; Control; EventArgs; Object

RadioButton1 Sample

This sample demonstrates using the RadioButton server control. The RadioButton server control permits you to intersperse the radio buttons in a group with other content in the page. The buttons in the sample are grouped logically because they all share the same GroupName property.

Namespaces used in this sample:

(none)

Classes used in this sample:

Group; Label; Button; RadioButton; Object; EventArgs

HtmlTextArea1 Sample

This sample illustrates using the HtmlTextArea control. The HtmlTextArea control is a multiline input control that lets the user enter text. The display width of HtmlTextArea is determined by its Cols property, and the display height is determined by the Rows property.

Namespaces used in this sample:

(none)

Classes used in this sample:

HtmlTextArea; Object; EventArgs

HyperLink1 Sample

This sample illustrates using a simple HyperLink control. The HyperLink control is used to navigate from the client to another page.

Namespaces used in this sample:

(none)

Classes used in this sample:

HyperLink; Url; Page; Object; EventArgs

ImageButton1 Sample

This sample demonstrates using the ImageButton to do a postback to the server. For additional button examples, see Button and LinkButton.

Namespaces used in this sample:

(none)

Classes used in this sample:

Image; Button; ImageButton; Label; Url; ImageClickEventArgs; EventArgs

HtmlInputImage1 Sample

This sample shows how an HtmlInputImage control is used to create a graphical button. Unlike HtmlButton controls, all standard browser clients support image buttons.

Namespaces used in this sample:

(none)

Classes used in this sample:

Image; Button; ImageClickEventArgs; EventArgs; HtmlInputImage

HtmlImage1 Sample

This sample shows how an HtmlImage control renders the image file specified by its Src property in an HTML <img> tag.

Namespaces used in this sample:

(none)

Classes used in this sample:

Image; HtmlImage; Object; EventArgs

CheckBox1 Sample

This sample illustrates using the CheckBox control. The CheckBox server control accepts Boolean (true or false) input. When checked, its Checked property is set to true. Typically, a check box is processed as one of several fields in a form; however, it can be used to trigger a postback to the server if its AutoPostBack property is set to true.

Namespaces used in this sample:

(none)

Classes used in this sample:

Label; CheckBox; Object; EventArgs

This sample illustrates using data binding with a DropDownList control.

Namespaces used in this sample:

(none)

Classes used in this sample:

Label; DropDownList; EventArgs; Object; ArrayList; Array; Page; DataBinding; Binding

ImageButton2 Sample

This sample illustrates using the ImageButton control. The ImageButton control's Click event supplies the x/y coordinates where the user clicked the image. This provides a means to respond differently depending on what part of the image is clicked.

Namespaces used in this sample:

(none)

Classes used in this sample:

Label; Image; Button; ImageButton; String; Url; EventArgs; ImageClickEventArgs

TextBox1 Sample

This sample illustrates using the TextBox control. The TextBox server control is an input control that lets the user enter text. By default, the TextMode property of TextBox is set to SingleLine, but you can modify the behavior of TextBox by setting the TextMode to Password or MultiLine.

Namespaces used in this sample:

(none)

Classes used in this sample:

Label; TextBox; Button; Object; EventArgs

ListBox2 Sample

This sample illustrates using data binding with a ListBox control.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListBox; Label; ArrayList; Object; Array; EventArgs; Binding; Page; DataBinding

CompareValidator1 Sample

This sample demonstrates using the CompareValidator server control to compare the value of one control to another, or to an explicit value in the control's ValueToCompare property.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; Button; TextBox; String; Page; Object; CompareValidator; ListBox; Control; Type; EventArgs; Font; Label

CheckBoxList1 Sample

This sample demonstrates using the CheckBoxList server control to provide a multiple-selection checked list. Like other list controls, CheckBoxList has an Items collection with members that correspond to each item in the list. To determine which items are selected, test the Selected property of each item.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; CheckBox; Button; CheckBoxList; Label; EventArgs; Object; Table; String

Image1 Sample

This sample illustrates using the Image control. The Image server control displays the image defined by its ImageUrl property.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; Image; Url; DropDownList; HtmlImage; Object; EventArgs

This sample illustrates using a simple DropDownList control. The DropDownList control provides a single-selection drop-down list.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; Label; DropDownList; Object; EventArgs

ListBox1 Sample

This sample illustrates using a simple ListBox control. The ListBox control provides a single-selection or multiselection list. To enable multiple selection, set the SelectionMode property to Multiple.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; ListBox; Label; Object; EventArgs

Panel1 Sample

This sample illustrates using the Panel server control. The Panel server control is a container for other controls. It is especially useful when you want to generate controls programmatically, or hide or show a group of controls.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; Panel; Control; Label; TextBox; String; DropDownList; LiteralControl; Literal; Button; Object; CheckBox; EventArgs; Page

ValidationSummary1 Sample

This sample illustrates displaying errors with a ValidationSummary control. A ValidationSummary control is displayed when the IsValid property of the page is set to false. It polls each of the validation controls on the page and aggregates the text messages exposed by each.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; RequiredFieldValidator; Button; DropDownList; Form; RadioButton; RadioButtonList; Message; TextBox; ValidationSummary; Control; Font; Type; Header; Object; Page; EventArgs

Table1 Sample

This sample illustrates using the Table control. The Table server control lets you build up a table programmatically by adding TableRows to the table's Rows collection, and TableCells to the row's Cells collection. You can add content to a table cell programmatically by adding controls to the cell's Controls collection.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; Table; DropDownList; Font; String; TableCell; TableRow; Control; Page; Object; Literal; LiteralControl; EventArgs

HtmlSelect2 Sample

This sample illustrates using data binding with an HtmlSelect control.

Namespaces used in this sample:

(none)

Classes used in this sample:

Object; EventArgs; Array; ArrayList; Page; HtmlSelect; DataBinding; Binding

HtmlInputHidden1 Sample

This sample shows how you can use hidden controls within HTML forms to embed invisible information that will be sent back to the server the next time a user performs a postback. This technique is commonly used to persist session-dependent information without using cookies or session state. The .NET Framework uses this feature of HTML to automatically store and restore the view state of ASP.NET server controls across round trips to the server.

Namespaces used in this sample:

(none)

Classes used in this sample:

Page; EventArgs; String; HtmlInputHidden

HtmlAnchor1 Sample

This sample demonstrates using the HtmlAnchor to navigate from the client page to another page.

Namespaces used in this sample:

(none)

Classes used in this sample:

Page; HtmlAnchor; Object; EventArgs

RegularExValidator1 Sample

This sample illustrates using the RegularExpressionValidator control. The RegularExpressionValidator server control checks whether the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in Social Security numbers, e-mail addresses, telephone numbers, postal codes, and so on.

Namespaces used in this sample:

(none)

Classes used in this sample:

RegularExpressionValidator; Font; TextBox; Page; Button; Object; Label; Control; EventArgs

Button2 Sample

This sample illustrates how a Button's commands can "bubble" to the OnItemCommand event of a list. The Button's CommandName and CommandArgument strings are passed to the OnItemCommand event, permitting the sample code to distinguish which button was clicked.

Namespaces used in this sample:

(none)

Classes used in this sample:

Repeater; Button; Container; Binder; DataBinder; Page; Label; Array; ArrayList; EventArgs; Object; RepeaterCommandEventArgs; Font; CommandEventArgs

Repeater1 Sample

This sample illustrates using a simple Repeater control. The Repeater server control displays data items in a repeating list. Like DataList, the content and layout of list items in Repeater is defined using templates. At a minimum, every Repeater must define an ItemTemplate; however, several optional templates can also be used to customize the appearance of the list.

Namespaces used in this sample:

(none)

Classes used in this sample:

Repeater; Header; Container; Binder; DataBinder; Array; ArrayList; Object; EventArgs; Page

ReqFieldValidator1 Sample

This sample illustrates using the RequiredFieldValidator control. The RequiredFieldValidator server control ensures that the user does not skip an entry. If the user inputs any value into the field identified by ControlToValidate, it is valid. If all the fields in the page are valid, the page is valid.

Namespaces used in this sample:

(none)

Classes used in this sample:

RequiredFieldValidator; Button; Font; TextBox; Control

Calendar5 Sample

This sample shows how you can make appointment-style calendars by adding content in the OnDayRender event. Two of the arguments for OnDayRender are the Day that is being rendered and its Cell object. Custom text can be added to the cell for a particular day by adding it as a LiteralControl to the Cell's Controls collection, as this sample shows.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Calendar; EventArgs; String; Font; DayRenderEventArgs; Control; Label; Page; Exception; TableCell; LiteralControl; CalendarDay; Table; Literal; Object

Calendar3 Sample

This sample shows how to use graphics to create a better-looking calendar. The Calendar control can use either text or graphics for its selection links.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Calendar; Font; Label; String; Graphics; Form; Header; EventArgs

Calendar4 Sample

This sample shows how the Calendar control can use text labels for week or month selection.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Font; Calendar; Label; String; Form; EventArgs; Header

HtmlTable1 Sample

This sample illustrates using the HtmlTable control. The HtmlTable control lets you build up a table programmatically by adding HtmlTableRow controls to the table's Rows collection and HtmlTableCell controls to the row's Cells collection. You can add content to a table cell programmatically by adding controls to the cell's Controls collection.

Namespaces used in this sample:

(none)

Classes used in this sample:

Table; HtmlTable; HtmlTableCell; HtmlTableRow; String; TableCell; TableRow; Control; Page; LiteralControl; Object; Literal; EventArgs

Xml1 Sample

This sample demonstrates using a simple XSL Transform document to format some XML into some HTML. The Xml server control can be used to write out an XML document or the results of an XSL Transform. The DocumentSource property specifies the XML document to be used. This document will be written directly to the output stream unless the TransformSource property is also specified. TransformSource must be a valid XSL Transform document and will be used to transform the XML document before its contents are written to the output stream.

Namespaces used in this sample:

(none)

Classes used in this sample:

Xml; Page