为了账号安全,请及时绑定邮箱和手机立即绑定

ListView控件,加一个客户端的JS代码,就不能插入、更新了!?

ListView控件,加一个客户端的JS代码,就不能插入、更新了!?

郎朗坤 2018-12-07 09:50:45
需求:一个用户表 字段为 名字,年龄 和性别 (性别是CheckBox ),要求:CheckBox 选中时为男性,不必填写年龄,(即插入项,年龄输入框隐藏,[color=#FF6600]用js实现[/color])不选中时为女,年龄框可见, js和程序效果我都实现了,奇哉怪也的是:InputAttributes["onchange"] = "changeed(this,'" + txtage.ClientID + "')";时, 插入,更新都不可用了!!即在 编辑、插入时,填好数据后,点更新或插入,数据会被清空,且维持编辑状态不变,经探索:毛病出在 "changeed(this,'" + txtage.ClientID + "')"; 把此javascript函数的形式改一下 即 不用txtage.ClientID 或其他字符串时,该现象就会消失!!不知所以然,望高手指教我的源代码在:http://www.w8le.com/lkfup/Solution1.rar   protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem || e.Item.ItemType == ListViewItemType.InsertItem) { CheckBox chb = e.Item.FindControl("UserGenderCheckBox") as CheckBox; TextBox txtage = e.Item.FindControl("UserAgeTextBox") as TextBox; if (chb != null && txtage !=null) { //chb.Attributes["onchange"] = "changeed(this,'" + txtage.ClientID + "')"; chb.InputAttributes["onchange"] = "changeed(this,'" + txtage.ClientID + "')"; } } }
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 496 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号