Breyta

Deila með


AutoCompleteType Enum

Definition

Represents the values that control the behavior of the AutoComplete feature in a TextBox control.

public enum class AutoCompleteType
public enum AutoCompleteType
type AutoCompleteType = 
Public Enum AutoCompleteType
Inheritance
AutoCompleteType

Fields

Name Value Description
None 0

No category is associated with the TextBox control. All TextBox controls with the same ID share the same value list.

Disabled 1

The AutoComplete feature is disabled for the TextBox control.

Cellular 2

The phone number for a mobile-phone category.

Company 3

The name of a business category.

Department 4

A department within a business category.

DisplayName 5

The name to display for the user category.

Email 6

The user's email address category.

FirstName 7

The first name category.

Gender 8

The gender of the user category.

HomeCity 9

The city for a home address category.

HomeCountryRegion 10

The country/region for a home address category.

HomeFax 11

The fax number for a home address category.

HomePhone 12

The phone number for a home address category.

HomeState 13

The state for a home address category.

HomeStreetAddress 14

The street for a home address category.

HomeZipCode 15

The ZIP code for a home address category.

Homepage 16

The URL to a Web site category.

JobTitle 17

The user's job title category.

LastName 18

The last name category.

MiddleName 19

The user's middle name category.

Notes 20

Any supplemental information to include in the form category.

Office 21

The location of the business office category.

Pager 22

The phone number for a pager category.

BusinessCity 23

The city for a business address category.

BusinessCountryRegion 24

The country/region for a business address category.

BusinessFax 25

The fax number for a business address category.

BusinessPhone 26

The phone number for a business address category.

BusinessState 27

The state for a business address category.

BusinessStreetAddress 28

The street for a business address category.

BusinessUrl 29

The URL to a business Web site category.

BusinessZipCode 30

The ZIP code for a business address category.

31

The keyword or keywords with which to search a Web page or Web site category.

Enabled 32

The AutoComplete feature is enabled for the TextBox control.

Examples

The following example demonstrates how to use the AutoCompleteType enumeration to specify the AutoComplete category for a TextBox control.

Important

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see 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>

Remarks

To assist with data entry, Internet Explorer 5 and later and some other browsers support a feature named AutoComplete. AutoComplete monitors a text box and stores a list of the values that the user has entered. When the user returns to the text box another time, the list of values is displayed. Instead of retyping a value, the user can simply select the value from this list.

Note

Not all browsers support the AutoComplete feature. Check with your browser to determine compatibility.

To control the behavior of the AutoComplete feature for a TextBox control, you use the AutoCompleteType property. The AutoCompleteType enumeration is used to represent the values that you can apply to the AutoCompleteType property.

By default, the AutoCompleteType property for a TextBox control is set to AutoCompleteType.None. With this setting, the TextBox control shares the list with other TextBox controls with the same ID across different pages. You can also share a list among TextBox controls based on a category instead of based on an ID. When you set the AutoCompleteType property to one of the category values (such as AutoCompleteType.FirstName or AutoCompleteType.LastName), all TextBox controls with the same category share the same list. You can disable the AutoComplete feature for a TextBox control by setting the AutoCompleteType property to AutoCompleteType.Disabled.

Refer to your browser documentation for details on configuring and enabling the AutoComplete feature. For example, to enable the AutoComplete feature in Internet Explorer version 5 or later, from the Tools menu, choose Internet Options. Then choose the Content tab. Choose the AutoComplete button to view and modify options for the AutoComplete feature.

Applies to

See also