Infolink

 

Search This Blog

Oct 16, 2012

Stop default Auto-Complete of ASP.net TextBox on all browser

If you use textBox properties AutoCompleteType="Disabled" it disables the autocompletes of textBox on only Internet explorer. There's another way to stop auto-complete on all browsers. Use autocomplete="off" on from tag instead of AutoCompleteType = "Disabled". Again you can use the TextBox1.Attributes.Add("autocomplete", "off"); to stop auto-complete on only specific TextBox control.

So, my findings are use the following code to stop autocomplete on specific control

 protected void Page_Load(object sender, EventArgs e)
    {
        TextBox1.Attributes.Add("autocomplete", "off");
    }
or

<asp:TextBox ID="TextBox2" runat="server" AutoComplete="off" 
        Width="248px"></asp:TextBox>
or Disable all auto-completes from all TextBox controls by

<form id="form1" runat="server" AutoComplete="off">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" 
            Width="248px"></asp:TextBox>
        <asp:Button ID="btn" Text="asdsad" runat="server" />
    </div>
</form>

2 comments:

  1. Really nice and informative thanks for sharing this.

    Web Development Company

    ReplyDelete
  2. i kept autocomplete="off" and autocompletetype="disabled" even though i'm getting autocomplete can anyone help me

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...