TextBox.AutoCompleteType Proprietà

Definizione

Ottiene o imposta un valore che indica il comportamento di completamento automatico del controllo TextBox.

public:
 virtual property System::Web::UI::WebControls::AutoCompleteType AutoCompleteType { System::Web::UI::WebControls::AutoCompleteType get(); void set(System::Web::UI::WebControls::AutoCompleteType value); };
[System.Web.UI.Themeable(false)]
public virtual System.Web.UI.WebControls.AutoCompleteType AutoCompleteType { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.AutoCompleteType : System.Web.UI.WebControls.AutoCompleteType with get, set
Public Overridable Property AutoCompleteType As AutoCompleteType

Valore della proprietà

Uno dei valori dell'enumerazione AutoCompleteType che indica il comportamento di completamento automatico del controllo TextBox. Il valore predefinito è None.

Attributi

Eccezioni

Il valore selezionato non corrisponde a uno dei valori dell'enumerazione AutoCompleteType.

Esempio

Nell'esempio di codice seguente viene illustrato come usare l'enumerazione per specificare la AutoCompleteType categoria Completamento automatico per un TextBox controllo.

Importante

L'esempio include una casella di testo che accetta l'input dell'utente e rappresenta quindi una potenziale minaccia alla sicurezza. Per impostazione predefinita, le pagine Web ASP.NET verificano che l'input dell'utente non includa script o elementi HTML. Per altre informazioni, vedere Cenni preliminari sugli attacchi tramite script.


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

Commenti

Per assistere la voce dei dati, Microsoft Internet Explorer 5 e versioni successive e altri browser supportano una funzionalità denominata Completamento automatico. Il completamento automatico monitora una casella di testo e crea un elenco di valori immessi dall'utente. Quando l'utente torna alla casella di testo in un secondo momento, viene visualizzato l'elenco. Anziché digitare un valore immesso in precedenza, l'utente può semplicemente selezionare il valore da questo elenco. Utilizzare la proprietà per controllare il AutoCompleteType comportamento della funzionalità Completamento automatico per un TextBox controllo. L'enumerazione System.Web.UI.WebControls.AutoCompleteType viene usata per rappresentare i valori che è possibile applicare alla AutoCompleteType proprietà.

Nota

Non tutti i browser supportano la funzionalità Completamento automatico. Controllare con il browser per determinare la compatibilità.

Per impostazione predefinita, la AutoCompleteType proprietà per un TextBox controllo è impostata su AutoCompleteType.None. Con questa impostazione, il TextBox controllo condivide l'elenco con altri TextBox controlli con la stessa ID proprietà in pagine diverse. È anche possibile condividere un elenco tra TextBox i controlli in base a una categoria, anziché una ID proprietà. Quando si imposta la AutoCompleteType proprietà su uno dei valori di categoria , ad esempio AutoCompleteType.FirstName, AutoCompleteType.LastNamee così via, tutti i TextBox controlli con la stessa categoria condividono lo stesso elenco. È possibile disabilitare la funzionalità Completamento automatico per un TextBox controllo impostando la AutoCompleteType proprietà su AutoCompleteType.Disabled.

Per informazioni dettagliate sulla configurazione e sull'abilitazione della funzionalità Completamento automatico, vedere la documentazione del browser. Ad esempio, per abilitare la funzionalità Completamento automatico in Internet Explorer versione 5 o successiva, selezionare Opzioni Internet dal menu Strumenti e quindi selezionare la scheda Contenuto . Fare clic sul pulsante Completamento automatico per visualizzare e modificare le varie opzioni del browser per la funzionalità Completamento automatico.

Per altre informazioni sulla funzionalità Completamento automatico in Internet Explorer, vedere Uso del completamento automatico in moduli HTML.

Questa proprietà non può essere impostata da temi oppure temi di fogli di stile. Per altre informazioni, vedere ThemeableAttribute e ASP.NET Temi e skin.

Si applica a

Vedi anche