开发者

disable browser autocomplete for ajax:AutoCompleteExtender

I'm using the .net ajaxtoolkit control AutoCompleteExtender. It works great but my firefox autocomplete overrides the values that the extender is returning (the firefox one lays on top of the control's).

is th开发者_如何学运维ere a way to disable the browser's version of autocomplete so that the .net one takes precendence?


Try this:

<asp:TextBox ID="txtFirstName" runat="server" autocomplete="off" />

The trick is setting autocomplete="off".

Actually it is defined in HTML 5 standards, but should work in most modern browsers.


If you are using an ASP.Net TextBox, you can simply add the following attribute to the control:

AutoCompleteType="Disabled"

Looks something like this:

<asp:TextBox ID="tbFirstName" runat="server" AutoCompleteType="Disabled" />

EDIT:

The property above only works for IE based browsers. However, if you add this attribute to the control:

autocomplete="off"

It should work in FireFox and Chrome.


Had the same problem in FireFox.

I have set the attribute in the page OnPreRender. (in my case a usercontrol)

protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        txtAutoComplete.Attributes.Add("autocomplete", "off");
    }    

Now it works like in IE.

Great!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜