How to Turn Off / Disable AutoComplete – ASP .Net

翻译 2011年01月24日 19:15:00

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

 

 

相关文章推荐

How to achive the CRUD in ASP.NET MVC(VS2010)

This demo shows how to achive the CRUD in ASP.NET MVC with VS2010. And the final output would be som...

How to install ASP.NET 1.1 with IIS7 on Vista and Windows 2008

OverviewYou can use the Web Platform Installer (Web PI) to easily install IIS, and applications that...

HOW TO Set Up Multi-Server ASP.NET Web Applications and Web Services

This step-by-step article discusses how to set up multi-server ASP.NET Web Applications and Web serv...

How to debug ASP.NET MVC using source code

最近在学习asp.net mvc的源代码。当我吧项目中的原来的System.Web.Mvc移除添加mvc源代码编译后的System.Web.Mvc经常遇到一个错误。 相关错误信息如下: c:\Us...
  • dz45693
  • dz45693
  • 2012年08月30日 14:48
  • 3863

HOW TO Analyze ASP.NET Web Application Performance by Using the Performance Administration Tool

This step-by-step article describes how to analyze ASP.NET Web application performance by using t...

csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C

/// ///參考: http://james.newtonking.com/json/help/index.html# /// 塗聚文(Geovin Du) 20141228 ...

How to convert XML to JSON in ASP.NET C#

原文:http://www.phdcc.com/xml2json.htm
  • Joyhen
  • Joyhen
  • 2014年07月09日 01:04
  • 1081

TextBox AutoComplete with ASP.NET and jQuery UI

This article demonstrates how to use the jQuery UI AutoComplete widget to consume an ASP.NET Web S...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:How to Turn Off / Disable AutoComplete – ASP .Net
举报原因:
原因补充:

(最多只允许输入30个字)