如何更改 AutoCompleteExtender 客户端 (javascript) 的 TargetControlID?
通常,我可以使用如下方式设置 TargetControlID 服务器端:
AutoCompleteExtender ace = new AutoCompleteExtender();
ace.ID = "AutoCompleteExtender1";
ace.TargetControlID = "whatever";
我知道如何获取 AutoCompleteExtender 客户端,但我也在寻找一种更新 TargetControlID 客户端的方法。有什么想法吗?
Normally, I can can set the TargetControlID server side using something like this:
AutoCompleteExtender ace = new AutoCompleteExtender();
ace.ID = "AutoCompleteExtender1";
ace.TargetControlID = "whatever";
I know how to grab the AutoCompleteExtender client side, but I am looking for a method to update the TargetControlID client side too. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遗憾的是,这对于现有的 AutoCompleteExtender 实例来说是不可能的。您可能对以下几种方法感兴趣,
这里的问题似乎是初始化版本在控制工具包的
init
阶段将附加事件附加到目标文本框(是的,客户端也有一个init阶段)。当初始化版本更改为目标时(如您想要的那样),则不会添加这些事件
keypress
、blur
等,因此您看不到任何更改。但如果您了解 javascript,您可以执行以下操作,使其适用于任何文本框。$create(Behavior,{properties},{events},interfaces,target);
其中
Behavior
AjaxControlToolkit.AutoCompleteBehavior
属性
是一个 javascript 对象,如下所示(还有更多属性,但这些就足够了
事件
还有更多可用的事件
目标
所有的事件、花哨的东西都吸引到这个文本框了
。
目标元素是最重要的,现在 一切都结束了,你可以一直通过javascript初始化一个自动完成的实例,只要确保ID已经不存在即可。
Well sadly this is not possible for existing instance of AutoCompleteExtender. There are a few methods that you might be interested in like below
the problem here seems initialized version attaches additional events to target textbox during
init
phase of the control toolkit( yeah client side too has ainit
phase). When a initialized version is made to change as the target (as you wanted to do) then these eventskeypress
,blur
etc are not added hence you don't see any changes. But if you knew javascript you can do the below to make it work with any textbox.$create(Behavior,{properties},{events},interfaces,target);
where
Behavior
AjaxControlToolkit.AutoCompleteBehavior
properties
is a javascript object as below (there are more properties but these suffice
Events
there are more events available
The Target
Target element is the most important. It is this text box that all the events ,bells and whistles attracted to.
$get("ELEMENT ID")
now that is all over , you can initialize a instance of auto complete though javascript all the time. Just make sure the ID already does not exist.
显然微软认为这并不重要,所以目前没有办法做到这一点:)
Apparently Microsoft didn't think was important, so there is not a way to do this at this time :)