How to set autocomplete = disabled globally for an ASP.NET application?

We have a mature program that processes sensitive data and has grown to several hundred pages and controls. Now you need to set autocomplete = off for all forms and text fields throughout the application. I do not believe there is a global web.config setting that will do this, so what would be the best way? My initial thought was to use the PageBase class (which inherits all pages) to dynamically search for all Form and TextBox controls and dynamically add the autocomplete = "off" attribute. Does this seem reasonable or is there a better way? Thanks for any recommendations.

+5
source share
4 answers

If all of your pages have a main page, try disabling auto-completion for input elements using jQuery on the main page.

You can place the code below on the main page

$(document).ready(function () { $("input").attr("autocomplete", "off"); }); 
+5
source

Always try to use BasePageand inheritsall of the pages from it, it is good practice, and it helps later on when the project is gradually becoming monster..... and in this case, if you have already done so IT .. one line code...

public abstract class BasePage : Page
{
    protected override void OnLoad(EventArgs e)
    {
        //Handling autocomplete issue generically
        if (this.Form != null)
        {
            this.Form.Attributes.Add("autocomplete", "off");
        }

        base.OnLoad(e);
    }
}
+7
source

autocomplete = "off" , . , IE .

, - , - , .

+3

MVC, Views/Shared _Layout.csstml :

$(document).ready(function () 
{ 
     $("input").attr("autocomplete", "off"); 
}); 

, , :

$("#myInputboxName").attr("autocomplete", "off");

myInputboxName - , .

+1

All Articles