0

I understand there are many questions and answers surrounding autocomplete and autofill for web browsers. I haven't seen this specific issue raised.

UPDATE: the autofill specifically happens when a partial postback executes inside an update panel

Recently, (chrome versions 70+?), Chrome has begun aggresively autofilling input fields in our webapp when a partial postback is executed. (We use asp.net web forms)

We use the partial postback to dynamically load a user control and add it to the DOM inside an update panel.

Specifically, inputs like the following simple snippet are being populated with an email:

<input type="search" class="newH4" placeholder="Search">

I've tried adding the autocomplete attribute with different values to no avail.

Here is a screenshot of the autofill:

enter image description here

Additionally I have other fields like entering a dollar amount which gets populated with the email as well. Is there a way to prevent this on the latest versions of chrome?

user3915135
  • 93
  • 1
  • 9

3 Answers3

1

If you have a password field in your form you can add this attribute - autocomplete="new-password"

<input type="password" placeholder="Password" autocomplete="new-password">

0

autocomplete="off" should be working, but in lieu of that working and given that it is not a password or email, you could feed it some random string to see if that helps

For example autocomplete="rjftgh"

kemotoe
  • 1,730
  • 13
  • 27
0

Note: simply changing the autocomplete attribute to a random string, or even a special one like 'new-password' does NOT work for this issue.

Ultimately I found a solution. It is more of a hack so I'm not too satisfied with it, but it comes from Mike Nelson's answer to the following question: Disabling Chrome Autofill

His solution involves adding input elements with their display property set to 'none' above the inputs that are being autofilled. The idea is that these hidden fields absorb the autofill instead.

I did also learn a bit more about the problem with ASP.NET and Update Panels as well. When the Update Panel triggers a partial postback, it uses an AJAX library. The library contacts the server to complete the update. Whatever AJAX is doing in the background, it is also triggering chrome's autofill logic to reexecute. In other words, whenever I dynamically add a user control, the first input field in that user control's html structure was being autofilled with the user's stored email.

Again, very strange and bad behavior, but the display 'none' input fields did the trick.

If Chrome changes their autofill logic again (they will), I'll update my answer with hopefully a better solution.

user3915135
  • 93
  • 1
  • 9