Your browser does not support JavaScript! Please enable script of your browser.
 
Coding is Rhyme
Handy Tricks For Beginners & Professionals
ASP.NET 4.5, 4.0 - Tutorial, Article, Archive, Pdf, Handy Tricks, Training, Code Snippets, Reference Manual, Server Controls, Directives, Event Handling, Database Access, Security, Debugging, Error Handling, Configuration and Deployment

Stop auto-fill in browsers for textbox

Posted By : Shailendra Chauhan, 26 Aug 2012
Updated On : 24 Jun 2014
Keywords : stop auto-complete in browser for textbox or form by programming,prevent auto-fill in browser,prevent auto-complete,hide auto-fill,hide auto-complete in browser

Today’s browsers like Chrome, Firefox, Internet Explorer and Safari has functionality of auto complete values in TextBoxes. If you have enabled this features in your browser, then each and every time when you start to enter value in TextBox you get a drop down of prefilled values in that TextBox. This feature of browser can be disabled by the programming for a specific web form like payment form and other confidential information form of a web application.

In chrome browser, we can enable auto-fill as shown below:

Suppose we have a below form for online payment of product by credit card or debit card then it is mandatory to stop auto complete functionality of browser so that browser doesn’t save the confidential information of a customer’s credit card or debit card.

We can turn off auto-fill for our complete form by setting autocomplete attribute value to off as shown below:

 <form id="Form1" method="post" runat="server" autocomplete="off">
 .
 .
</form> 

We can also turn off auto-fill for a particular TextBox by setting autocomplete attribute value to off as shown below:

 <asp:TextBox Runat="server" ID="txtConfidential" autocomplete="off"></asp:TextBox> 

We can also do this from code behind also like as:

 txtConfidential.Attributes.Add("autocomplete", "off"); 

After doing one of above code you will see that there is no auto-fill.

Summary

In this article, I explain how can you stop auto-complete in TextBox by programming. I hope you will use this trick in your web form. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.

About the Author
Shailendra Chauhan works as Sr. Software Engineer at reputed MNC and has more than 5 years of hand over Microsoft .NET technologies. He is a .NET Consultant and is the founder & chief editor of www.dotnet-tricks.com and www.dotnetinterviewtricks.com blogs. He is an author of books ASP.NET MVC Interview Questions and Answers & LINQ Interview Questions and Answers.
He loves to work with web applications and mobile apps using Microsoft technology including ASP.NET, MVC, C#, SQL Server, WCF, Web API, Entity Framework,Cloud Computing, Windows Azure, jQuery, jQuery Mobile, Knockout.js, Angular.js and many more web technologies. More...
 
 
Recommended Articles!
 
 
Search Articles
 
 
Subscribe & follow Us
 
 
Protected by Copyscape Web Plagiarism Check
 
Free .NET Interview Books
Learn In Hindi
Browse By Category
 
Recent Articles
 
Popular Articles
 
Like us on Facebook
 
Featured AD
Join our Training programs in Delhi/Noida on ASP.NET MVC, WCF, EF, jQuery - call us    +91-9871749695