AutoCompleteType 枚举

定义

表示控制 TextBox 控件中自动完成功能的行为的值。

public enum class AutoCompleteType
public enum AutoCompleteType
type AutoCompleteType = 
Public Enum AutoCompleteType
继承
AutoCompleteType

字段

BusinessCity 23

办公地址所在城市类别。

BusinessCountryRegion 24

办公地址所在国家/地区类别。

BusinessFax 25

办公地址的传真号码类别。

BusinessPhone 26

办公地址的电话号码类别。

BusinessState 27

办公地址所在州类别。

BusinessStreetAddress 28

办公地址所在街道类别。

BusinessUrl 29

业务网站的 URL 类别。

BusinessZipCode 30

办公地址的邮政编码类别。

Cellular 2

移动电话号码类别。

Company 3

企业名称类别。

Department 4

企业内的部门类别。

Disabled 1

TextBox 控件禁用自动完成功能。

DisplayName 5

为该用户显示的名称类别。

Email 6

用户的电子邮件地址类别。

Enabled 32

TextBox 控件启用自动完成功能。

FirstName 7

姓氏类别。

Gender 8

用户性别类别。

HomeCity 9

家庭地址所在城市类别。

HomeCountryRegion 10

家庭地址所在国家/地区类别。

HomeFax 11

家庭地址的传真号码类别。

Homepage 16

网站的 URL 类别。

HomePhone 12

家庭地址的电话号码类别。

HomeState 13

家庭地址所在州类别。

HomeStreetAddress 14

家庭地址所在街道类别。

HomeZipCode 15

家庭地址的邮政编码类别。

JobTitle 17

用户的职务类别。

LastName 18

姓氏类别。

MiddleName 19

用户的中名类别。

None 0

无任何类别与 TextBox 控件相关联。 具有相同 TextBox 的所有 ID 控件都共享同一值列表。

Notes 20

要包含在窗体类别中的任何补充信息。

Office 21

业务办公室所在位置类别。

Pager 22

寻呼机号码类别。

31

用于搜索网页或网站的关键字类别。

示例

以下示例演示如何使用 AutoCompleteType 枚举为控件指定自动完成类别 TextBox

重要

此示例具有一个接受用户输入的文本框,这是一个潜在的安全威胁。 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。 有关详细信息,请参阅脚本侵入概述


<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>AutoCompleteType example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <!-- You need to enable the AutoComplete feature on -->
      <!-- a browser that supports it (such as Internet   -->
      <!-- Explorer 5.0 and later) for this sample to     -->
      <!-- work. The AutoComplete lists are created after -->
      <!-- the Submit button is clicked.                  -->
    
      <h3>AutoCompleteType example</h3>
    
      Enter values in the text boxes and click the Submit <br/>
      button. <br/><br/> 
    
      <!-- The following TextBox controls have different  -->
      <!-- categories assigned to their AutoCompleteType  -->
      <!-- properties.                                    -->
      First Name:<br/>
      <asp:textbox id="FirstNameTextBox"
        autocompletetype="FirstName" 
        runat="server"/>
      <br/>
        
      Last Name:<br/>   
      <asp:textbox id="LastNameTextBox"
        autocompletetype="LastName" 
        runat="server"/>
      <br/>
      
      Email:<br/>   
      <asp:textbox id="EmailTextBox"
        autocompletetype="Email" 
        runat="server"/>
      <br/>
      
      <!-- The following TextBox controls have the same   -->
      <!-- categories assigned to their AutoCompleteType  -->
      <!-- properties. They share the same AutoComplete   -->
      <!-- list.                                          -->
      Phone Line #1:<br/>
      <asp:textbox id="Phone1TextBox"
        autocompletetype="HomePhone" 
        runat="server"/>
      <br/>
      
      Phone Line #2:<br/>
      <asp:textbox id="Phone2TextBox"
        autocompletetype="HomePhone" 
        runat="server"/>
      <br/>

    
      <!-- The following TextBox control has its          -->
      <!-- AutoCompleteType property set to               -->
      <!-- AutoCompleteType.None. All TextBox controls    -->
      <!-- with the same ID across different pages share  -->
      <!-- the same AutoComplete list.                    -->
      Category:<br/>   
      <asp:textbox id="CategoryTextBox"
        autocompletetype="None" 
        runat="server"/>
      <br/>
        
      <!-- The following TextBox control has the          -->
      <!-- AutoComplete feature disabled.                 -->
      Comments:<br/>   
      <asp:textbox id="CommentsTextBox"
        autocompletetype="Disabled" 
        runat="server"/>
      <br/>
      <br/><br/>  
      
      <asp:button id="SubmitButton"
        text="Submit"
        runat="Server"/>
    
    </form>
  </body>
</html>

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>AutoCompleteType example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <!-- You need to enable the AutoComplete feature on -->
      <!-- a browser that supports it (such as Internet   -->
      <!-- Explorer 5.0 and later) for this sample to     -->
      <!-- work. The AutoComplete lists are created after -->
      <!-- the Submit button is clicked.                  -->
    
      <h3>AutoCompleteType example</h3>
    
      Enter values in the text boxes and click the Submit <br/>
      button. <br/><br/> 
    
      <!-- The following TextBox controls have different  -->
      <!-- categories assigned to their AutoCompleteType  -->
      <!-- properties.                                    -->
      First Name:<br/>
      <asp:textbox id="FirstNameTextBox"
        autocompletetype="FirstName" 
        runat="server"/>
      <br/>
        
      Last Name:<br/>   
      <asp:textbox id="LastNameTextBox"
        autocompletetype="LastName" 
        runat="server"/>
      <br/>
      
      Email:<br/>   
      <asp:textbox id="EmailTextBox"
        autocompletetype="Email" 
        runat="server"/>
      <br/>
      
      <!-- The following TextBox controls have the same   -->
      <!-- categories assigned to their AutoCompleteType  -->
      <!-- properties. They share the same AutoComplete   -->
      <!-- list.                                          -->
      Phone Line #1:<br/>
      <asp:textbox id="Phone1TextBox"
        autocompletetype="HomePhone" 
        runat="server"/>
      <br/>
      
      Phone Line #2:<br/>
      <asp:textbox id="Phone2TextBox"
        autocompletetype="HomePhone" 
        runat="server"/>
      <br/>

    
      <!-- The following TextBox control has its          -->
      <!-- AutoCompleteType property set to               -->
      <!-- AutoCompleteType.None. All TextBox controls    -->
      <!-- with the same ID across different pages share  -->
      <!-- the same AutoComplete list.                    -->
      Category:<br/>   
      <asp:textbox id="CategoryTextBox"
        autocompletetype="None" 
        runat="server"/>
      <br/>
        
      <!-- The following TextBox control has the          -->
      <!-- AutoComplete feature disabled.                 -->
      Comments:<br/>   
      <asp:textbox id="CommentsTextBox"
        autocompletetype="Disabled" 
        runat="server"/>
      <br/>
      <br/><br/>  
      
      <asp:button id="SubmitButton"
        text="Submit"
        runat="Server"/>
    
    </form>
  </body>
</html>

注解

为了协助数据输入,Internet Explorer 5 及更高版本和其他一些浏览器支持名为“自动完成”的功能。 自动完成监视文本框,并存储用户输入的值的列表。 当用户再次返回到文本框时,将显示值列表。 用户只能从此列表中选择值,而不是重新设置值。

备注

并非所有浏览器都支持自动完成功能。 请与浏览器联系以确定兼容性。

若要控制控件的“自动完成”功能 TextBox 的行为,请使用该 AutoCompleteType 属性。 枚举 AutoCompleteType 用于表示可应用于属性 AutoCompleteType 的值。

默认情况下, AutoCompleteType 控件的属性 TextBox 设置为 AutoCompleteType.None。 通过此设置,该 TextBox 控件在不同的页面中与其他 TextBox 具有相同控件 ID 的列表共享。 还可以基于类别而不是基于类别ID在控件之间TextBox共享列表。 将属性设置为 AutoCompleteType 某个类别值 ((例如 AutoCompleteType.FirstNameAutoCompleteType.LastName) )时,具有相同类别的所有 TextBox 控件共享同一列表。 You can disable the AutoComplete feature for a TextBox control by setting the AutoCompleteType property to AutoCompleteType.Disabled.

有关配置和启用自动完成功能的详细信息,请参阅浏览器文档。 例如,若要在 Internet Explorer 版本 5 或更高版本中启用自动完成功能,请在 “工具” 菜单中选择 “Internet 选项”。 然后选择“ 内容 ”选项卡。选择 “自动完成 ”按钮以查看和修改自动完成功能的选项。

适用于

另请参阅