Webkit browser autocomplete doesn't work with textboxes in ASP UpdatePanel
I've got several pages with UpdatePanels with asp textboxes and submit buttons inside. However, none of them trigger Chrome or Safari's autofill/autocomplete functions, where things you've previously entered gets suggested.
It seems to work fine with regular postbacks, but inside UpdatePanels I can't seem to get this to work.
It would seem开发者_JAVA技巧 to me that this should be a known problem, but I can't find any information about it.
It seems like Chrome is remembering those input values when there is a full post/submit event. Here is two other question in SO regarding the same issue.
browser autocomplete/saved form not work in ajax request and How to store to browser auto-complete/auto-fill when using AJAX calls instead of standard form submit
I tried to fake a submit to another page with get action and "NoContent" status code so that chrome would remember the values. No luck with that too. If it would work it would still not be a good way to do this though.
Have you tried changing the UpdateMode property?
I think you're experiencing a classic problem with ASP.NET UpdatePanel controls and jQuery.
The problem is the following:
jQuery code (in your case it's auto-complete, but it can be anything) works fine on the page load, but it stops working after a partial postback. If this is the case, there is a couple of things you need to understand about using jQuery with UpdatePanel controls.
First, all event bindings defined in $(document).ready
stop working after the first partial postback (and I assume that your button click causes a partial postback). This is just the way ASP.NET works. So how do you fix it?
Well, there are several ways to address this problem. A typical recommendation is to substitute $(document).ready
with the ASP.NET AJAX's own pageLoad event. This may solve one problem, but it will most likely cause more issues because now you will be binding events on every partial postback causing repeated execution of event handlers on a single event. You can address some issues by calling unbind for your selector before performing any bindings. For simple event bindings, you can keep using $(document).ready
with the live function (instead of click, hover, etc).
I haven't used jQuery plugins with UpdatePanel, so I can't say for sure what you need to do, but once you understand what is happening, it should not be hard to find the right approach. To learn more about this problem and possible solutions, please read Dave Ward's article $(document).ready() and pageLoad() are not the same! (the article includes several examples).
Hope this might help!
I had the same issue identified by OP. However, cause was different than other answers here.
My issue was that the postbacks triggered by an <asp:LinkButton>
were not being picked up as a form submit by the browser.
Example:
<asp:LinkButton runat="server" OnClick="codebehind_function">Click here</asp:LinkButton>
Adding the PostBackUrl
attribute fixed it!
<asp:LinkButton runat="server" OnClick="codebehind_function" PostBackUrl="#">Click here</asp:LinkButton>
精彩评论