-1

I have a section in my asp website (After logging in), where user accounts can be added. The problem is that I user inputs of type password and email for the user's email address and password fields. For some reason, it auto populates these fields based on the values it memorized from the login page. The following image presents my scenario. Any suggestions?

enter image description here

<tr>
    <td>Email </td>
    <td><asp:TextBox ID="txtEmailToAdd" runat="server" Width="200px" autocomplete="off"></asp:TextBox></td>
    <td></td>
</tr>
<tr>
    <td>Department </td>
    <td> 
        <asp:DropDownList ID="cboDeptToAdd" runat="server" Width="200px">
        </asp:DropDownList>
    </td>
    <td></td>
</tr>
<tr>
    <td>Position </td>
    <td> 
        <asp:DropDownList ID="cboPosToAdd" runat="server" Width="200px">
        </asp:DropDownList>
    </td>
    <td></td>
</tr>
<tr>
    <td>Password </td>
    <td><asp:TextBox ID="txtPasswordToAdd" runat="server" Width="200px" TextMode="Password" autocomplete="off"></asp:TextBox></td>
    <td></td>
</tr>
<tr>
    <td>Confirm Password </td>
    <td><asp:TextBox ID="txtPasswordConfirmToAdd" runat="server"    Width="200px" TextMode="Password" autocomplete="off"></asp:TextBox></td>
    <td><asp:Button ID="btnAddUser" runat="server" Text="Add User" 
            Width="170px" onclientclick="return ValidateAdd();" 
            onclick="btnAddUser_Click" /></td>
</tr>
Maciej A. Czyzewski
  • 1,539
  • 1
  • 13
  • 24
Dean Martin
  • 1,223
  • 3
  • 18
  • 27
  • 2
    possible duplicate of [How do you disable browser Autocomplete on web form field / input tag?](http://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag) – Tdelang Jul 31 '13 at 13:52
  • it is already in this http://stackoverflow.com/questions/582244/is-there-a-w3c-valid-way-to-disable-autocomplete-in-a-html-form – Deepak.Aggrawal Jul 31 '13 at 13:53
  • It is because of your browser's autocomplete behaviour. Not about your program. – zkanoca Jul 31 '13 at 13:54
  • How can I go about disabling this programatically? – Dean Martin Jul 31 '13 at 13:55
  • @ReidGarwin You do not want to access `autocomplete` directly from `textbox` since it is a server control. However, you can use `AutoCompleteType`. See my answer. – Win Jul 31 '13 at 14:40
  • Clear your browser history , Then check ! –  Jul 31 '13 at 15:04
  • Look : http://stackoverflow.com/a/17973935/1193035 –  Jul 31 '13 at 15:31

5 Answers5

1

Just give different names for the input

<input type="text" name = "email_to_add_user"/>
0

If you are using HTML5 then you can disable form auto-completion by using the autocomplete attribute:

<input type="text" id="id1" autocomplete='off'/>
Abhitalks
  • 27,721
  • 5
  • 58
  • 81
  • Thanks, This does work with HTML5. Unfortunately not for HTML <5 – Dean Martin Jul 31 '13 at 14:01
  • @abhi ha ha . Very funny answer . The OP have asp.net textbox() , how do you asked to html??? ... –  Jul 31 '13 at 15:00
  • @RameshRams I don't understand your English? What does "how do you asked to html" mean? HTML attributes can be defined on on server-side controls as well. What's the problem you are having? And why the downvote? Do you have any other better solution or just trolling? – Abhitalks Aug 01 '13 at 05:35
  • I have already meat the problem !!!! It's not a autocomplete problem.it's a browser problem.. The OP have asp.net textbox. but your answer is html textbox with html 5 ? what's tha link between asp.net textbox and html input field ?? is it same???? –  Aug 01 '13 at 05:58
  • @RameshRams please think before commenting. Yes. they are the same. The server controls are rendered as html elements only. You can define any html attribute on a server-side control as is. Moreover, the Op asked if he could do it programatically. See his 4th comment on his question- "How can I go about disabling this programatically?". Please first read everything before you just start putting your comments everywhere. – Abhitalks Aug 01 '13 at 06:05
0

This could be the browser auto filling the form fields. Try disabling that option in your browser.

user2426014
  • 159
  • 1
  • 7
0

Maybe you send the model used for log in page. If you have @Html.EditorFor or @Html.TextBoxFor in your View it autocompletes with the value from your model.

Put value="" attribute on your text fields

Cosmin
  • 2,184
  • 21
  • 38
  • 1
    @Kosmo OP is using traditional ASP.Net (not ASP.Net MVC). – Win Jul 31 '13 at 15:04
  • @Html.TextBoxFor . wooow... You go to MVC.. lol.. what a fun !! !!!! But the OP asked for asp.net webform , not a Razor view !! –  Jul 31 '13 at 15:05
0

You want AutoCompleteType="Disabled" for ASP.Net TextBox control.

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

It will render as

<input name="txtEmailToAdd" type="text" autocomplete="off" id="txtEmailToAdd" />

Here is the more information about AutoCompleteType Property.

Win
  • 61,100
  • 13
  • 102
  • 181
  • I think . this is for correct answer . or clear your browser history !!! –  Jul 31 '13 at 15:06
  • 1
    @RameshRams Clearing browser history is not even an option, because we cannot access or control client's browser. – Win Jul 31 '13 at 15:10
  • This is a browser issue !! if you click the save the values option in browser .it's shown . –  Jul 31 '13 at 15:14
  • http://stackoverflow.com/a/17973935/1193035 –  Jul 31 '13 at 15:32
  • 1
    @RameshRams ***Autofill forms and saving password are totally two different things*** *(Please look at browser's setting)*. Besides, you cannot ask everyone to clear browser cache and disable autofill before accessing your website; it'll piss off your users. – Win Jul 31 '13 at 15:40