AutoCompleteType 枚举  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示控制 TextBox 控件中自动完成功能的行为的值。
public enum class AutoCompleteTypepublic enum AutoCompleteTypetype AutoCompleteType = Public Enum 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 | 为该用户显示的名称类别。 | 
| 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 | |
| Notes | 20 | 要包含在窗体类别中的任何补充信息。 | 
| Office | 21 | 业务办公室所在位置类别。 | 
| Pager | 22 | 寻呼机号码类别。 | 
| Search | 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.LastName) 等AutoCompleteType.FirstName类别值之一时,具有相同类别的所有控件将TextBox共享同一列表。 可以通过将 属性设置为 AutoCompleteTypeAutoCompleteType.Disabled来禁用控件的TextBox自动完成功能。
有关配置和启用自动完成功能的详细信息,请参阅浏览器文档。 例如,若要在 Internet Explorer 版本 5 或更高版本中启用自动完成功能,请从 “工具 ”菜单中选择“ Internet 选项”。 然后选择“ 内容 ”选项卡。选择“ 自动完成 ”按钮以查看和修改“自动完成”功能的选项。