Export (0) Print
Expand All
Expand Minimize

AutoCompleteType Enumeration

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

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public enum AutoCompleteType
public enum AutoCompleteType
public enum AutoCompleteType

 Member nameDescription
BusinessCityThe city for a business address category. 
BusinessCountryRegionThe country/region for a business address category. 
BusinessFaxThe fax number for a business address category. 
BusinessPhoneThe phone number for a business address category. 
BusinessStateThe state for a business address category. 
BusinessStreetAddressThe street for a business address category. 
BusinessUrlThe URL to a business Web site category. 
BusinessZipCodeThe ZIP code for a business address category. 
CellularThe phone number for a mobile-phone category. 
CompanyThe name of a business category. 
DepartmentA department within a business category. 
DisabledThe AutoComplete feature is disabled for the TextBox control. 
DisplayNameThe name to display for the user category. 
EmailThe user's e-mail address category. 
FirstNameThe first name of the user category. 
GenderThe gender of the user category. 
HomeCityThe city for a home address category. 
HomeCountryRegionThe country/region for a home address category. 
HomeFaxThe fax number for a home address category. 
HomepageThe URL to a Web site category. 
HomePhoneThe phone number for a home address category. 
HomeStateThe state for a home address category. 
HomeStreetAddressThe street for a home address category. 
HomeZipCodeThe ZIP code for a home address category. 
JobTitleThe user's job title category. 
LastNameThe user's last name category. 
MiddleNameThe user's middle name category. 
NoneNo category is associated with the TextBox control. All TextBox controls with the same ID share the same value list. 
NotesAny supplemental information to include in the form category. 
OfficeThe location of the business office category. 
PagerThe phone number for a pager category. 
SearchThe keyword or keywords with which to search a Web page or Web site category. 

To assist with data entry, Internet Explorer 5 and later and Netscape support a feature called AutoComplete. AutoComplete monitors a text box and creates a list of values entered by the user. When the user returns to the text box at a later time, the list is displayed. Instead of retyping a previously entered value, the user can simply select the value from this list. To control the behavior of the AutoComplete feature for a TextBox control, use the AutoCompleteType property. The AutoCompleteType enumeration is used to represent the values that you can apply to the AutoCompleteType property.

NoteNote:

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

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 an ID. When you set the AutoCompleteType property to one of the category values (such as AutoCompleteType.FirstName, AutoCompleteType.LastName, and so on), 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, select Internet Options from the Tools menu; then select the Content tab. Click the AutoComplete button to view and modify the various browser options for the AutoComplete feature.

For more information on the AutoComplete feature in Internet Explorer, search for the Using AutoComplete in HTML Forms topic in the MSDN Library at http://msdn.microsoft.com/library.

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

Security noteSecurity Note:

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 (Visual Studio).


<%@ 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>


Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft