jQuery 自动完成在 AutoPostBack 上丢失文本
我在 ASP.Net Webform 上有一个 jQuery 自动完成字段,到目前为止一切都运行良好。 我还有一个 DropDownList,我需要使用 AutoPostBack 触发 onSelectedIndexChanged 。
当我更改代码以执行 AutoPostBack 时,包含 jQuery AutoComplete 的文本字段将返回空白。 但是,如果我查看页面的源代码,文本位于文本字段中。 如果我现在发布表单,页面将发回一个空白字段。 我的 Google-Fu 在这方面很弱,因为我无法想出任何解决方法。
有没有人遇到过这样的问题:自动完成字段在自动回传上被清空,您是如何解决这个问题的?
如果确实有必要,我可以发布代码,但由于公司政策,我需要先对其中的大部分内容进行清理。
I have a jQuery Autocomplete field on an ASP.Net Webform and everything has been working great until now. I also have a DropDownList that I have a need to fire onSelectedIndexChanged with AutoPostBack.
When I changed my code to do the AutoPostBack, the text field that has the jQuery AutoComplete on it comes back blank. However, if I look at the source of the page, the text is in the text field. If I now post the form, the page will send back a blank field. My Google-Fu is weak on this one, as I could not come up with any workaround for it.
Has anyone had any issues like this with the Autocomplete field getting blanked out on an AutoPostBack, and how did you get around it?
I can post code if it's really necessary, but I'd need to sanitize a lot of it before I could due to company policy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自动完成字段是如何初始化的? 是否在从服务器加载页面时或通过 document.ready 上的自动完成 jQuery 插件将其设置为空字符串?
如果插件的源代码将 document.ready 上的文本框设置为空字符串,请尝试以下操作:
How is the autocomplete field being initialized? Is it being set to empty string either on page load from server or by the autocomplete jQuery plugin on document.ready?
If the source code for the plug-in is setting the textbox to empty string on document.ready then try the following:
如果您使用 jQuery 自动完成插件 1.1,
* 修订版: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
在选项中添加“autoPostBackSelection: false,” 例如:
之后,在“return true; at”之前添加此内容“selectCurrent() 函数的末尾。
例子:
If you use jQuery Autocomplete plugin 1.1,
* Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
Add "autoPostBackSelection: false," in the options Ex:
After, add this just before the "return true; at the end of the "selectCurrent() function.
Example: