Saturday, December 7, 2013

How to stop auto-fill in browsers for textbox using asp.net

Hi Friends,

Here I will explain how to stop auto-fill in browsers for textbox using asp.net.

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

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

  • You 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>

  • You can also do this from code behind like below: 

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