Ajax Toolkit Combobox:丢失焦点事件可能吗?

编程入门 行业动态 更新时间:2024-10-24 00:22:48
本文介绍了Ajax Toolkit Combobox:丢失焦点事件可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

Hi All, I have 2 Ajax Toolkit's Comboboxes on my asp 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 : www.w3schools/jsref/event_onblur.asp [ ^ ]。 这是使用jQuery完成的方式:api.jquery/blur/ [ ^ ]。 你实际使用 onblur 但你的处理程序没有做任何有用的事情。该怎么办?这将取决于你想要达到的目标。
-SA
Yes, the event is called obclur: www.w3schools/jsref/event_onblur.asp[^]. This is how it's done using jQuery: api.jquery/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:丢失焦点事件可能吗?

本文发布于:2023-11-25 02:10:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627892.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   焦点   Ajax   Toolkit   Combobox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!