文本框的textChaned事件



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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值