Many browsers support autocomplete feature, making our life easier. With this feature, browser remembers the input values we make on certain fields e.g. text field and when we go visit the webpage later on, browser make suggestions with those past values we have entered.
Sometimes this is not a desirable feature. Lets say you are on a shared computer and using your credit card to make a purchase. You sure don’t want the computer remember your credit card info.
So how you can turn off or disable autocomplete on a entire web page in asp .net?
Very simple.
<form id="Form1" method="post" runat="server" autocomplete="off">
So how you can turn off or disable autocomplete on a textbox in asp .net?
<asp:TextBox Runat="server" ID="Textbox1" autocomplete="off"></asp:TextBox>
Note that intellisense might not detect autocomplete listed. However it would work just fine if you put that on.
---------------
许多浏览器支持 Auto-Complete功能(就是自动填写的那个烦人功能);由于这个功能,浏览器就能记住某些文本框中曾经填写过的内容,比如用户名、姓名等等。
有时候这些自动填写的功能就变得非常令人烦恼 - 例如:当你在大家共用的一台计算机上用自己的信用卡购买产品时,你显然不希望该计算机记住你的信用卡号码。
所以,如何才能在ASP.Net里禁用这种自动填写的功能呢?
很简单:
<form id="Form1" method="post" runat="server" autocomplete="off">
如何禁用部分特定的文本框呢?
<asp:TextBox Runat="server" ID="Textbox1" autocomplete="off">
VisualStudio 可能不会检测到autocomplete这个属性 (因为不是.NET所支持的) - 但是他在ASP.NET编译后被生成HTML就会自动生效。