共用方式為


Toolbox, HTML tab

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The HTML tab of the Toolbox provides components that are useful on web pages and web forms. To view this tab, first open a document for editing in the HTML designer. On the View menu, click Toolbox, and then click the HTML tab of the Toolbox.

To create an instance of a tool on the HTML tab, either double-click the tool to add it to your document at the current insertion point, or select the tool and drag it to the desired position on the editing surface.

UI elements

The following tools are available by default on the HTML tab.

Pointer

ASP.NET Mobile Designer HTMLpage Pointer

This tool is selected by default when any Toolbox tab opens. It cannot be deleted. The pointer enables you to drag objects onto the Design view surface, resize them, and reposition them on the page or form. For more information, see Toolbox.

Input (Button)

HTML web page button

Inserts an input element of type="button". To change the text that is displayed, edit the name property. By default, id="Button1" is inserted for the first button, id="Button2" for the second, and so on.

When you drag Input (Button) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Button1" type="button" value="Button" name="Button1">

Input (Reset)

HTMLpageResetButton screenshot

Inserts an input element of type="reset". To change the text that is displayed, edit the name property. By default, id="Reset1" is inserted for the first reset button, id="Reset2" for the second, and so on.

When you drag Input (Reset) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Reset1" type="reset" value="Reset" name="Reset1">

Input (Submit)

HTMLpageToolbarSubmitButton screenshot

Inserts an input element of type="submit". To change the text that is displayed, edit the name property. By default, id="Submit1" is inserted for the first submit button, id="Submit2" for the second, and so on.

When you drag Input (Submit) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Submit1" type="submit" value="Submit" name="Submit1">

Input (Text)

HTMLpageToolbarTextField screenshot

Inserts an input element of type="text" in your document. To change the default text that is displayed, edit the value attribute. By default, id="Text1" is inserted for the first text field, id="Text2" for the second, and so on.

When you drag Input (Text) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Text1" TYPE="text" value="Text Field" name="Text1">

Important

It is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET Web Pages (Razor) Sites.

Input (File)

HTML page File Field

Inserts an input element of type="file" in your document. By default, id="File1" is inserted for the first file field, id="File2" for the second, and so on.

When you drag Input (File) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="File1" type="file" name="File1">

Important

It is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET Web Pages (Razor) Sites.

Input (Password)

Visual Studio Password Field

Inserts an input element of type="password". By default, id="Password1" is inserted for the first password field, id="Password2" for the second, and so on.

When you drag Input (Password) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Password1" type="password" name="Password1">

Important

If your application transmits user names and passwords, you should configure your website to use Secure Sockets Layer (SSL) to encrypt the transmission. For more information, see Securing Connections. Additionally, it is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET Web Pages (Razor) Sites.

Input (Check box)

HTML webpage Toolbox Checkbox Option

Inserts an input element of type="checkbox". To change the text that is displayed, edit the name property. By default, id="Checkbox1" is inserted for the first check box, id="Checkbox2" for the second, and so on.

When you drag Input (Check box) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Checkbox1" type="checkbox" name="Checkbox1">

Input (Radio)

VisualStudioHTMLpageRadioButton screenshot

Inserts an input element of type="radio". To change the text that is displayed, edit the name property. By default, id="Radio1" is inserted for the first radio button, id="Radio2" for the second, and so on.

When you drag Input (Radio) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Radio1" type="radio" name="Radio1">

Input (Hidden)

HTML page Hidden Item

Inserts an input element of type="hidden". By default, id="Hidden1" is inserted for the first hidden field, id="Hidden2" for the second, and so on.

When you drag Input (Hidden) onto the Design view surface, HTML markup like the following is inserted into your document:

<input id="Hidden1" type="hidden" name="Hidden1">

Textarea

HTMLpage Toolbar Text Area

Inserts a textarea element. You can resize the text area, or use its scroll bars to view text that extends beyond its display area. To change the default text that is displayed, edit the value attribute. By default, id="textarea1" is inserted the first text area, id=" textarea 2" for the second, and so on.

When you drag Textarea onto the Design view surface, HTML markup like the following is inserted into your document:

<textarea id=" textarea 1 name=" textarea 1" rows=2 cols=20></textarea>

Important

It is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET Web Pages (Razor) Sites.

Table

HTMLpageToolbarTable screenshot

Inserts a table element.

When you drag Table onto the Design view surface, HTML markup like the following is inserted into your document:

<table cellspacing="1" width="75%" border=1> <tr><td></td></tr></table>

Image

HTML page Image Item

Inserts an img element. Edit this element to specify its src and its alt text.

When you drag Image onto the Design view surface, HTML markup like the following is inserted into your document:

<img alt="" src="">

Select

HTML page Toolbox Dropdown

Inserts a dropdown select element (without a size attribute). By default, id="select1" is inserted for the first list box, id="select2" for the second, and so on.

When you drag Select onto the Design view surface, HTML markup like the following is inserted into your document:

<select id="select1" name="select1"><option selected></option></select>

You can create a multi-line select element by increasing the value of the size property.

Horizontal Rule

HTML page Horizontal Rule Item

Inserts an hr element. To increase the thickness of the line, edit the size attribute.

When you drag Horizontal Rule onto the Design view surface, HTML markup like the following is inserted into your document:

<hr width="100%" size=1>

Div

HTML page Label

Inserts a div element that includes an ms_positioning="FlowLayout" attribute. Except for the width and height, this item is identical to a Flow Layout Panel. To format the text that is contained within the div element, add a class="stylename" attribute to the opening tag.

When you drag Div onto the Design view surface, HTML markup like the following is inserted into your document:

<div ms_positioning="FlowLayout" style="width: 70px; position: relative; height: 15px">Label</div>

See also