亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 關注
  • 501 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號