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

用來搜尋 Web 網頁或網站的關鍵字分類。

範例

下列範例示範如何使用 AutoCompleteType 列舉來指定控制項的 TextBox AutoComplete 類別。

重要

這個範例有一個可接受使用者輸入的文字方塊,這可能會造成安全性威脅。 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。


<%@ 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 和更新版本和一些其他瀏覽器支援名為 AutoComplete 的功能。 AutoComplete 會監視文字方塊,並儲存使用者輸入的值清單。 當使用者再次返回文字方塊時,會顯示值清單。 使用者可以直接從此清單中選取值,而不是重新套用值。

注意

並非所有瀏覽器都支援自動完成功能。 請洽詢您的瀏覽器以判斷相容性。

若要控制控制項的 AutoComplete 功能 TextBox 行為,請使用 AutoCompleteType 屬性。 列舉 AutoCompleteType 是用來表示您可以套用至 屬性的值 AutoCompleteType

根據預設, AutoCompleteType 控制項的 TextBox 屬性會設定為 AutoCompleteType.None 。 透過此設定,控制項會 TextBox 與其他跨不同 TextBox 頁面具有相同的控制項 ID 共用清單。 您也可以根據類別在控制項之間 TextBox 共用清單,而不是根據 。 ID 當您將 AutoCompleteType 屬性設定為其中一個類別值 (例如 AutoCompleteType.FirstNameAutoCompleteType.LastName) 時,具有相同類別的所有 TextBox 控制項都會共用相同的清單。 您可以將 屬性 AutoCompleteType.Disabled 設定 AutoCompleteType 為 ,以停用控制項的 TextBox AutoComplete 功能。

如需設定和啟用自動完成功能的詳細資訊,請參閱瀏覽器檔。 例如,若要在 Internet Explorer 第 5 版或更新版本中啟用自動完成功能,請從 [ 工具 ] 功能表選擇 [ 網際網路選項]。 然後選擇 [ 內容] 索引標籤。選擇 [ 自動完成 ] 按鈕以檢視和修改自動完成功能的選項。

適用於

另請參閱