Поделиться через


HTML Input Controls

The following controls, which are based on the HTML INPUT element, are available on the HTML tab of the Toolbox:

  • Input (Button) control: INPUT type="button" element

  • Input (Checkbox) control: INPUT type="checkbox" element

  • Input (File) control: INPUT type="file" element

  • Input (Hidden) control: INPUT type="hidden" element

  • Input (Password) control: INPUT type="password" element

  • Input (Radio) control: INPUT type="radio" element

  • Input (Reset) control: INPUT type="reset" element

  • Input (Submit) control: INPUT type="submit" element

  • Input (Text) control: INPUT type="text" element

HTML server controls added from the Toolbox to a page in Visual Studio are simply HTML elements with certain attributes already set. You can also create HTML elements in Source view by typing markup.

By default, HTML elements on a Web Forms page are not available to the server; they are treated as markup that is passed through to the browser. However, if you add an id attribute and the attribute runat="server", ASP.NET recognizes the element as a control on the page and you can program it with server-based code.

Unlike other HTML elements, if you convert an HTML INPUT element to an ASP.NET server control, it is not created as an instance of the HtmlInputControl class. You cannot create an instance of the HtmlInputControl class directly. Instead, this class is inherited by the classes listed in the table below.

The following table lists the type that is used to instantiate INPUT elements as ASP.NET server controls if the markup contains the attribute runat="server" and an id attribute.

Server control

Type

Button control

HtmlInputButton

CheckBox control

HtmlInputCheckBox

File Field control

HtmlInputFile

Hidden control

HtmlInputHidden

Password control

HtmlInputPassword

Radio Button control

HtmlInputRadioButton

Reset Button control

HtmlInputReset

Submit Button control

HtmlInputSubmit

Text Field control

HtmlInputText

For more information, see ASP.NET Web Server Controls Overview. For a list of HTML controls, see HTML Server Controls.

Security noteSecurity Note:

User input in a Web Forms page can include potentially malicious client script. By default, the Web Forms page validates that user input does not include script or HTML elements. For more information, see Script Exploits Overview and How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings.

ASP.NET server controls that render as an INPUT element are as follows:

See Also

Tasks

How to: Convert HTML Server Controls to HTML Elements

Other Resources

Adding HTML Server Controls to an ASP.NET Web Page