How to Turn Off / Disable AutoComplete – ASP .Net

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.

Code:
<form id="Form1" method="post" runat="server" autocomplete="off">

So how you can turn off or disable autocomplete on a textbox in asp .net?

Code:
<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就会自动生效。

 

 

转载于:https://www.cnblogs.com/mleader1/archive/2011/01/24/2392419.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值