Sometimes
user want to disable history from the text box. Suppose when user enter
information like credit card number and again if user enter another
number then no previous value should be available in the text box's
history.
Here 5,8 are those numbers which were entered by user for this textbox, this clearly shows textbox is caching history.
Here 5,8 are those numbers which were entered by user for this textbox, this clearly shows textbox is caching history.
I am going to disclose two ways to solve this problem which are shown below:-
1. By Using Asp.Net Property :
2. By Using JavaScript Code :
<asp:TextBox ID="txtNumber" runat="server" AutoCompleteType="Disabled"></asp:TextBox>
2. By Using JavaScript Code :
<asp:TextBox ID="txtSearch" runat="server" onfocus="disableautocomplete(this.id);" ></asp:TextBox>
JavaScript Functionfunction disableautocomplete(id) {
var passwordControl = document.getElementById(id);
passwordControl.setAttribute("autocomplete", "off");
}
I think, best option would be to write a JavaScript function rather than just using 'AutoCompleteType' Property bcoz it ensures working in all browsers rather than just major browsers.
That’s it!!…..Happy Programming...
At the time of Page Load :- TextBox1.Attributes.Add("autocomplete", "off")
ReplyDelete