HTML Server Controls

IOTA^_^    

Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Appendix C.  ASP.NET Controls: Properties and Methods


This section lists the details for each HTML server control in the Web forms framework. Recall that any HTML element can be turned into an HTML server control simply by adding the runat="server" attribute. All the predefined HTML server controls are documented here, and those that aren't predefined all inherit the same common properties, shown in the next section.

Common HTML Server Control Properties

Table C.4 lists the properties shared by all HTML server controls inherited from the System.Web.UI.HtmlControls.HtmlControl class.

Table C.4. Shared HTML Server Control Properties
Property Description
Attributes Retrieves all attribute name and value pairs.
Disabled Specifies whether a control is read-only in the Web page.
Style Retrieves all cascading style sheet (CSS) properties.
TagName Retrieves the name of the control.

Table C.5 lists the properties shared by all HTML server input controls (such as HtmlInputText, HtmlInputCheckBox, and so on) inherited from the System.Web.UI. HtmlControls.HtmlInputControl class.

Table C.5. Shared HTML Server Input Control Properties
Property Description
Name Specifies a unique name for the control.
Type Retrieves the type of the control.
Value Specifies the contents of a control.

Table C.6 lists the properties shared by all HTML server container controls (such as HtmlTable, HtmlForm, and so on) inherited from the System.Web.UI. HtmlControls.HtmlContainerControl class.

Table C.6. Shared HTML Server Control Container Properties
Property Description
InnerHtml Specifies the content between the opening and closing tags of the control.
InnerText Same as InnerHtml, but provides HTML encoding and decoding.

The HTML Server Controls

This section lists all properties and methods for the predefined HTML server controls. Note that additional properties are inherited from other objects (refer to previous two sections).

HtmlAnchor

This control represents an anchor or link in a Web page. Table C.7 lists the properties and events of the HtmlAnchor server control. The syntax is

 <a href="..." ... runat="server">...</a> 

Table C.7. Properties and Events of the HtmlAnchor Control
Property Description
Href Specifies the URL target.
Name Specifies the bookmark name for the control.
Target Specifies the target window to load the URL.
Title Specifies the title displayed by the browser for a Web page.
Event Description
ServerClick Occurs when the user clicks the control.

HtmlButton

Represents a button (available only on browsers that support HTML 4.0). Table C.8 lists the property and event of the HtmlButton server control. The syntax is

 <button ... runat="server"> 

Table C.8. Property and Event of the HtmlButton Control
Property Description
CausesValidation Indicates if the HtmlButton should perform validation when clicked.
Event Description
ServerClick Occurs when the user clicks the control.

HtmlForm

Represents an HTML form. Table C.9 lists the properties of the HtmlForm server control. The syntax is

 <form ... runat="server"> 

Table C.9. Properties of the HtmlForm Control
Property Description
Action Specifies the URL of the page that handles and processes the form's submission.
EncType The encoding used by browsers to post the form's data, such as "text/plain" or "image/jpeg".
Method Specifies how the form posts data to the server, such as "Get" or "Post".
Name Specifies the identity of the form.
Target Specifies the target window to load the URL.

HtmlImage

Represents an image in a Web page. Table C.10 lists the properties of the HtmlImage server control. The syntax is

 <img ... runat="server"> 

Table C.10. Properties of the HtmlImage Control
Property Description
Align The alignment of the image with respect to other items on the page.
Alt The alternative text caption for the image.
Border The width of the frame containing the image.
Height The height of the image.
Src The source of the image file.
Width The width of the image.

HtmlInputButton

Represents an input button control in an HTML form. Table C.11 lists the events of the HtmlInputButton server control. The syntax is

 <input type="button" ... runat="server"> 

Table C.11. Events of the HtmlInputButton Control
Property Description
ServerClick Occurs when the user clicks the control.

HtmlInputCheckBox

Represents a check box. Table C.12 lists the properties and events of the HtmlInputCheckBox server control. The syntax is

 <input type="checkbox" ... runat="server"> 

Table C.12. Properties and Events of the HtmlInputCheckBox Control
Property Description
Checked Indicates whether the control is checked.
Event Description
ServerChange Occurs when the form is posted and the state of the control is different from the previous post.

HtmlInputControl

Represents a generic input control used with HTML forms. Table C.13 lists the properties of the HtmlInputControl server control. The syntax is

 <input ... runat="server"> 

Table C.13. Properties of the HtmlInputControl Control
Property Description
Name The unique name for the control.
Type Retrieves the type of the control. Value could be "text", "password", "checkbox", "radio", "button", "submit", "reset", "file", "hidden", or "image". This property is read-only.
Value The contents of the control.

HtmlInputFile

Represents a form element that allows users to upload files to the server. Table C.14 lists the properties of the HtmlInputFile server control. The syntax is

 <input type="file" ... runat="server"> 

Table C.14. Properties of the HtmlInputFile Control
Property Description
Accept Specifies a list of MIME types of files to accept.
MaxLength The maximum length of file to accept.
PostedFile Gets access to the posted file. Returns an HttpPostedFile object.
Size The width of the text box in which the file path is entered.

HtmlInputHidden

Represents a hidden form field. Table C.15 lists the events of the HtmlInputHidden server control. The syntax is

 <input type="hidden" ... runat="server"> 

Table C.15. Events of the HtmlInputHidden Control
Event Description
ServerChange Occurs when the posted content is different than the previous post.

HtmlInputImage

Represents an input button using an image instead of a push-style button. Table C.16 lists the properties and events of the HtmlInputImage server control. The syntax is

 <input type="image" ... runat="server"> 

Table C.16. Properties and Events of the HtmlInputImage Control
Property Description
Align The alignment of the image with respect to other elements on the page.
Alt The alternative text displayed for the image.
Border The width of the frame containing the image.
Src The location of the image file.
Event Description
ServerClick Occurs when the user clicks the control.

HtmlInputRadio

Represents a radio form element. Table C.17 lists the properties of the HtmlInputRadio server control. The syntax is

 <input type="radio" ... runat="server"> 

Table C.17. Properties of the HtmlInputRadio Control
Property Description
Checked Indicates whether the control is selected.

HtmlInputText

Represents a text box form element. Table C.18 lists the properties of the HtmlInputText server control. The syntax is

 <input type="text" ... runat="server"> 

Table C.18. Properties of the HtmlInputText Control
Property Description
MaxLength The maximum number of characters that can be entered into this element.
Size The visible width of the element in characters.
Value The content of the control.

HtmlSelect

Represents a drop-down box of selectable items. Table C.19 lists the properties and events of the HtmlSelect server control. The syntax is

 <select ... runat="server"> 

Table C.19. Properties and Events of the HtmlSelect Control
Property Description
DataMember The name of a data table or view to use (used when the DataSource property is assigned a DataSet).
DataSource The data source to populate this control with.
DataTextField A field in the data source that is displayed in the drop-down box.
DataValueField A field in the data source that specifies the value for each selectable item.
InnerHtml The HTML code contained within the opening and closing tags of this control.
InnerText The text-only portion of the content contained within the opening and closing tags of this control.
Items Gets the list of items in the select box. Returns a ListItemCollection object.
Multiple Specifies whether multiple values can be selected at once (using the Shift key or Control key).
SelectedIndex The index number of the currently selected item in the list. If multiple items are selected, this value represents the first item.
Size The number of list items to display at once.
Value The value of the currently selected item.
Event Description
ServerChange Occurs when the posted selected item is different than in the previous post.

HtmlTable, HtmlTableCell, and HtmlTableRow

These controls represent a table and its cells and rows. Table C.20 lists the properties common to all these server controls.

Table C.20. Properties Shared by the HtmlTable, HtmlTableCell, and HtmlTableRow Controls
Property Description
Align The alignment of the control as opposed to other elements on the page.
BGColor The background color of the control.
BorderColor The color of the border around the control.
Height The height of the control.

Table C.21 lists the properties of the HtmlTable server control. The syntax is

 <table ... runat="server"> 

Table C.21. Properties of the HtmlTable Control
Property Description
Border The width of the border around the table and in between cells.
CellPadding The padding within cells.
CellSpacing The spacing between cells.
InnerHtml The HTML code contained within the opening and closing tags of this control.
InnerText The text-only portion of the content contained within the opening and closing tags of this control.
Rows Returns an HtmlRowCollection object representing all rows in the table.

Table C.22 lists the properties of the HtmlTableCell server control. The syntax is

 <td ... runat="server"> 

Table C.22. Properties of the HtmlTableCell Control
Property Description
ColSpan The number of columns this cell spans.
NoWrap Indicates whether the text within this cell should be allowed to wrap.
RowSpan The number of rows this cell spans.
VAlign The vertical alignment of text within this cell.
Width The width of the table cell.

Table C.23 lists the properties of the HtmlTableRow server control. The syntax is

 <tr ... runat="server"> 

Table C.23. Properties of the HtmlTableRow Control
Property Description
Cells Returns an HtmlTableCellCollection representing the cells contained in this row.
InnerHtml The HTML code contained within the opening and closing tags of this control.
InnerText The text-only portion of the content contained within the opening and closing tags of this control.
VAlign The vertical alignment of the cells within this row.

HtmlTextArea

This control represents an HTML textarea element. Table C.24 lists the properties and events of the HtmlTextArea server control. The syntax is

 <textarea ... runat="server"> 

Table C.24. Properties and Events of the HtmlTextArea Control
Property Description
Cols The number of columns (in characters) of this element.
Name Specifies the unique name for the control.
Rows The number of visible rows.
Value The content contained within this control.
Event Description
ServerChange Occurs when the content of this control has changed from one post to another.


    IOTA^_^    
    Top


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net