Prevent textbox autofill with previously entered values

I have an asp page with some Textbox controls on it.

By default, the browser will suggest previously entered values for each box.

I’d like to prevent that behavior for some of the textboxes.

Is there a way to reliably do that across all major browsers?

I’ve tried setting


But that seems to have no effect in Firefox.

Here is an image of the behavior I’m trying to prevent.

enter image description here


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

For firefox


<asp:TextBox id="Textbox1" runat="server" autocomplete="off"></asp:TextBox>

Or from the CodeBehind:
Textbox1.Attributes.Add("autocomplete", "off");

Method 2

Autocomplete need to set off from textbox

<asp:TextBox ID="TextBox1" runat="server" autocomplete="off"></asp:TextBox>

Method 3

By making AutoCompleteType=”Disabled”,

    <asp:TextBox runat="server" ID="txt_userid" AutoCompleteType="Disabled"></asp:TextBox>

By setting autocomplete=”off”,

    <asp:TextBox runat="server" ID="txt_userid" autocomplete="off"></asp:TextBox>

By Setting Form autocomplete=”off”,

    <form id="form1" runat="server" autocomplete="off">  
    //your content  

By using code in .cs page,

    protected void Page_Load(object sender, EventArgs e)   
        if (!Page.IsPostBack)  
            txt_userid.Attributes.Add("autocomplete", "off");  

By Using Jquery

    <head runat = "server" >  
        < title > < /title> < script src = "Scripts/jquery-1.6.4.min.js" > < /script> < script type = "text/javascript" >  
            $('#txt_userid').attr('autocomplete', 'off');  
    //document.getElementById("txt_userid").autocomplete = "off"  
    < /script>

and here is my textbox in ,

    <asp:TextBox runat="server" ID="txt_userid" ></asp:TextBox>

By Setting textbox attribute in code,

    protected void Page_Load(object sender, EventArgs e)   
        if (!Page.IsPostBack)  
            txt_userid.Attributes.Add("autocomplete", "off");  

Method 4

This is the answer.

<asp:TextBox id="yourtextBoxname" runat="server" AutoCompleteType="Disabled"></asp:TextBox>


If you still get the pre-filled boxes for example in the Firefox browser then its the browser’s fault. You have to go

‘Options’ –> ‘Security'(tab) –> Untick

‘Remember password for sites and click on Saved Passwords button to delete any details that the browser has saved.

This should solve the problem

Method 5

Trying from the CodeBehind:

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

Method 6

Adding autocomplete="new-password" to the password field did the trick. Removed auto filling of both user name and password fields in Chrome.

<input type="password" name="whatever" autocomplete="new-password" />

Method 7

Please note that for Chrome to work properly it needs to be autocomplete="false"

Method 8

This works for me

   <script type="text/javascript">
        var c = document.getElementById("<%=TextBox1.ClientID %>"); =
        function (event, ui) 
        { this.value = ""; return false; }

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x