文本框的textChaned事件

来源:互联网 发布:女鞋淘宝店铺名称 编辑:程序博客网 时间:2024/06/05 02:18
AutoPostBack="True"后在执行其他事件前会先执行这个TextChanged事件,这样如果是提交按钮就会要点两下在page_load事件里加入 txtComplex.Attributes.Add("onpropertychange", "this.onchange()"); txtComplex.Attributes.Add("oninput", "this.onchange()");//兼容firefox但这样做有个缺点,就是你没输入一个字符,就提交服务器一次。
另一种方法,可以在客服端添加脚本,比如文本框TextChanged事件时清空单选框组的选项
script>
function clearRadio(RadioGname)
{
    //debugger;
    var RadioButtonList = document.getElementsByName(RadioGname);
    for (var i=0; i<RadioButtonList.length;i++)
    {
        var item = RadioButtonList[i];
        item.checked = false;
    }  
}
</script>
rbChoice.UniqueID //得到客户端生成的控件name
rbChoice.ClientID//得到客户端生成的控件ID
txtComplex.Attributes.Add("onpropertychange", "clearRadio('"+ rbChoice.UniqueID +"');");
txtComplex.Attributes.Add("oninput", "clearRadio('" + rbChoice.UniqueID + "');");//兼容firefox