Ajax Toolkit Combobox:丢失焦点事件可能吗? [英] Ajax Toolkit Combobox: Lost Focus event possible?

查看:107
本文介绍了Ajax Toolkit Combobox:丢失焦点事件可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的asp.net网页上有2个Ajax Toolkit的Comboboxes,我想在离开时在第2个组合框中设置一个值(根据第一个组合框的选择,从第一个组合框中失去焦点)。我可以通过添加属性'onblur'来调用javascript函数来捕获普通文本框的丢失焦点事件。但是,此方法不适用于组合框。有没有办法实现这个目标?如果我在客户端或服务器端执行此操作并不重要。



普通文本框的代码:



代码落后:

Hi All,

I have 2 Ajax Toolkit's Comboboxes on my asp.net web page, and I would like to set a value in the 2nd combobox at leaving (losing focus) from the 1st combobox depending on the selection of the 1st combobox. I can capture a lost focus event for a normal text box by adding an attribute 'onblur' to call a javascript function. However, this method does not work for the combobox. Is there any way to achieve this? It does not matter if I do this on client side or server side.

The code for the normal text box:

Code behind:

txtDescription.Attributes.Add("onblur", "javascript:Set_Value();")





JavaScript:



JavaScript:

<script type="text/javascript">
      function Set_Value() {
          debugger;
          var intNum = 1;
      }
  </script>





感谢您提前。



Thanks for advance.

推荐答案

是的,该事件被称为 obclur

http://www.w3schools.com/jsref/event_onblur.asp [ ^ ]。



这是使用jQuery完成的方式:http://api.jquery.com/blur/ [ ^ ]。







你实际使用 onblur 但你的处理程序没有做任何有用的事情。该怎么办?这将取决于你想要达到的目标。



-SA
Yes, the event is called obclur:
http://www.w3schools.com/jsref/event_onblur.asp[^].

This is how it's done using jQuery: http://api.jquery.com/blur/[^].



You actually use onblur but your handler does not do anything useful. What to do? It will depend on what you try to achieve.

—SA


我决定不出于其他原因使用Ajax组合框,但我仍然想出如何为组合框添加'onBlur'属性。您必须将'onBlur'属性添加到combobox.controls中的文本框控件,而不是直接将其添加到组合框本身。



I decided not to use the Ajax combobox for other reasons, but I still figured out how to add 'onBlur' attribute for the combobox. You have to add 'onBlur' attribute to the textbox control in the combobox.controls instead of adding it directly to the combobox itself.

Dim txtStartTime As TextBox
txtStartTime = cbxStartTime.FindControl("cbxStartTime_TextBox")
If txtStartTime IsNot Nothing Then
    txtStartTime.Attributes.Add("onBlur", "javascript:Set_EndDateTime(null, this);")
End If





其中cbxStartTime是Ajax组合框,txtStartTime是内部控件。 />


此方法将触发,但行为看起来不像失去焦点。它更像是'在所选项目上更改'。我想,只要用户从组合框中选择一个项目,文本框就会失去焦点。



where cbxStartTime is the Ajax combobox, and txtStartTime is the inner control.

This method will fire, but the behavior does not look like 'on lost focus'. It is more like 'on selected item changed'. I guess the textbox loses its focus as soon as a user select an item from the combobox.


这篇关于Ajax Toolkit Combobox:丢失焦点事件可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆