日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
淺析ASP.NETCheckBoxList

ASP.NET CheckBoxList 實現(xiàn)單選

為企業(yè)提供網(wǎng)站建設(shè)、做網(wǎng)站、網(wǎng)站優(yōu)化、全網(wǎng)營銷推廣、競價托管、品牌運營等營銷獲客服務(wù)。成都創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營銷運營團隊,以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認(rèn)可!

一看標(biāo)題估計大家都開始懷疑了:單選?為什么不直接使用 RadioButtonList ?
是的。你是對的。然而,實際應(yīng)用中需求千變?nèi)f化,誰讓我們的客戶夠 BT 呢?

主要代碼

只有一個通用的ASP.NET CheckBoxList_Click 函數(shù),
需要注意的是ASP.NET CheckBoxList 可以呈現(xiàn)為 table 布局,也可以呈現(xiàn)為流布局(使用 span 做外部容器)

我的習(xí)慣是,腳本代碼中,盡量不直接引用 html id,因為對于服務(wù)器控件對應(yīng)的是 ClientID,而ClientID與控件層次關(guān)聯(lián)的,不利于代碼移植復(fù)用,因此盡可能選擇直接傳遞對象,通過 DOM 獲取相關(guān)的父控件和子控件。

 
 
 
 
  1. functionCheckBoxList_Click(sender)
  2. {
  3. varcontainer=sender.parentNode;
  4. if(container.tagName.toUpperCase()=="TD"){
  5. //服務(wù)器控件設(shè)置呈現(xiàn)為table布局(默認(rèn)設(shè)置),否則使用流布局
  6. containercontainer=container.parentNode.parentNode;
  7. //層次:
  8. <button id="pl6kb"></button>
  9. }
  10. varchkList=container.getElementsByTagName("input");
  11. varsenderState=sender.checked;
  12. for(vari=0;i;i++){
  13. chkList[i].checked=false;
  14. }
  15. sender.checked=senderState;
  16. }
  17.  
     
     
     
    1. 單選效果的CheckBoxList

    2. <divstyledivstyle="float:left">
    3. 靜態(tài)項

    4. <asp:CheckBoxListIDasp:CheckBoxListID=
      "CheckBoxList1"BorderWidth="1"runat="server"RepeatLayout="Flow">
    5. <asp:ListItemonclickasp:ListItemonclick=
      "CheckBoxList_Click(this)"Value="Item1">Item1
    6. <asp:ListItemonclickasp:ListItemonclick=
      "CheckBoxList_Click(this)"Value="Item2">Item2
    7. <asp:ListItemonclickasp:ListItemonclick=
      "CheckBoxList_Click(this)"Value="Item3">Item3
    8. <asp:ListItemonclickasp:ListItemonclick=
      "CheckBoxList_Click(this)"Value="Item4">Item4
    9. <asp:ListItemonclickasp:ListItemonclick=
      "CheckBoxList_Click(this)"Value="Item5">Item5
    10. <divstyledivstyle="float:left;padding-left:100px">
    11. 綁定項

    12. <asp:CheckBoxListIDasp:CheckBoxListID="CheckBoxList2"BorderWidth="1"runat=
      "server"DataTextField="Value"DataValueField="Key"OnDataBound=
      "CheckBoxList2_DataBound">

    兼容性
    IE 6 SP6,  FF 2.0,  Opera 9.2 測試通過

    頁面效果


    標(biāo)題名稱:淺析ASP.NETCheckBoxList
    本文鏈接:http://www.5511xx.com/article/dhodcse.html