views:

884

answers:

2

The ASP.Net TextBox control has an AutoCompleteType property that takes an AutoCompleteType enumeration value.

First, is this property commonly used in actual development? Or is "browser autocomplete" turned off and Ajax autocomplete used instead?

Second, are you constrained to only the values in the AutoCompleteType enum? Can you extend the AutoCompleteType enum to contain custom values?

+1  A: 

The AutoCompleteType enum is merely a simple way of referencing the autocomplete expando attribute exposed by the html tag. This attribute can be any string, with "off" being reserved for disabling the feature. Any textboxes that use a specific string will start autocompleting from the same shared list of previous entries.

For example: If you set autocomplete on 2 boxes to "car", the next time you visit a form with another box with autocomplete set to "car" your previously used choices will become available.

cnobles
When I try `<asp:TextBox ... AutoCompleteType="car" ... />`in Visual Studio, the page will not compile - I get the error `Cannot create an object of type 'System.Web.UI.WebControls.AutoCompleteType' from its string representation 'car' for the 'AutoCompleteType' property.`
Nate
Sorry, I wasn't clear. The html attribute itself can be set to anything. Microsoft likes to "help" and gives you a limited list of selections via the enumeration. If you want a different value, you'll need to set the attribute directly via SetAttribute.
cnobles
OK - thanks for pointing me to the setAttribute() method... so AutoCompleteType sounds useless :) or at least extraneous...
Nate
A: 

Setting autocompletetype="disabled" didn't actually turn off auto complete in Firefox. The only time autocompletetype works is when the client is using IE. (Yay asp.net browser sniffing.)

Using the non-standard attribute autocomplete="off" works--and you can use this in your markup instead of using setattribute().

Broam