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”);

5 thoughts on “Disable AutoComplete in Asp.NET

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s