Disable AutoComplete in Asp.NET

Most Browsers have a feature called AutoComplete which saves information that has previously been inputted like web addresses and form data. But sometimes, you may want to disable this feature for inputs like credit card information.

ASP.NET has the ability to override the user’s choice with the autocomplete attribute by setting it to off. This can be added to a form tag or any TextBox control and can be done using one of the following two properties:

  • AutoComplete=”Off”
  • AutoCompleteType=”Disabled”

View some examples after the break…

Below are some examples with AutoComplete=”Off”

  • <form Runat=”server” AutoComplete=”Off”></form>
  • <asp:TextBox ID=”txtCardNumber” runat=”server” AutoComplete=”Off” />
  • at runtime: txtCardNumber.Attributes.Add( “AutoComplete”, “Off” );

 You can find more info here or here

And next some examples with AutoCompleteType=”Disabled” 

  • <form Runat=”server” AutoCompleteType=”Disabled”></form>
  • <asp:TextBox ID=”txtCardNumber” runat=”server” AutoCompleteType=”Disabled”/>
  • at runtime: txtCardNumber.Attributes.Add( “AutoCompleteType”, “Disabled”);
Advertisements

5 Responses to “Disable AutoComplete in Asp.NET”

  1. santosh Says:

    This is Awsome and Nice post for the cause of developers

  2. Carlos Ornelas Says:

    Does this function exists on ASP 3.0?

  3. mayank Says:

    gud work.. i really need this.
    thankx

  4. Tejas Says:

    Thank’s
    It is really helpfull……


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: