如何为组合框下拉选择触发客户端事件 [英] How to trigger a client side event for a combobox dropdown selection

查看:59
本文介绍了如何为组合框下拉选择触发客户端事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在webform页面中使用Ajaxtoolkit ComboBox,我需要检查用户是否已选择(单击)显示的下拉值。我需要做这个客户端。是否有任何方法可以添加一个javascript函数,该函数将在下拉值更改时触发。 SelectedIndexChanged事件直到回发才触发,这是不好的。



这里是项目代码

I am using an Ajaxtoolkit ComboBox in a webform page and I need to check if the user has selected (click on) a drop down value other than the one displayed. I need to do this client side. Is there any way of adding a javascript function which will trigger when the dropdown value is changed. The SelectedIndexChanged event does not trigger until postback which is no good.

here is the code from the project

<br />
<ajaxToolkit:ComboBox ID="ComboBox1" runat="server" AutoPostBack="false"   OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged" >
</ajaxToolkit:ComboBox>
 <br />










public void Page_Load(object sender, EventArgs e)
        {
            ComboBox1.Items.Add("Test Item 1");
            ComboBox1.Items.Add("Test Item 2");
            ComboBox1.Items.Add("Test Item 3");
        }

        public void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }







感谢任何有关如何实现此建议的建议



我尝试过的事情:



搜索了一些例子 - 但没有找到。试图添加一个eventlistner但是没有用。




appreciate any advise on how to achieve this

What I have tried:

searched for examples - but found none. Tried adding an eventlistner but did not work.

推荐答案

<script type="text/javascript" language="javascript">
function SetAllCheckBoxes(FormName, AreaID, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.getElementById(AreaID).getElementsByTagName('input');
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
</script>


这篇关于如何为组合框下拉选择触发客户端事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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