国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET中WebForm組件CheckBoxList編程(4)

2024-07-10 12:55:47
字體:
來源:轉載
供稿:網友
國內最大的酷站演示中心!
五. 文中源程序代碼(check.aspx)和執行的界面:
  
    下圖是執行了下列源程序代碼(check.aspx)后,生成的界面:
  
  
  
    check.aspx源程序代碼如下:
  
  
  <% @ page language = "c#" %>
  
  <html >
  <head >
  <title > checkboxlist組件演示程序 </title >
  <script runat = "server" >
   protected void button_click ( object sender , eventargs e )
   {
    //組件中的檢查框中的文本和選框的排列位置
    switch ( cboalign . selectedindex )
    {
     case 0 :
      chklist . textalign = textalign . left ;
      break ;
     case 1 :
      chklist . textalign = textalign . right ;
      break ;
    }
  
    //組件中各個檢查框布局
    switch ( cborepeatlayout . selectedindex )
    {
     case 0 :
      chklist . repeatlayout = repeatlayout . table ;
      break ;
     case 1 :
      chklist . repeatlayout = repeatlayout . flow ;
      break ;
    }
  
    //組件中各個檢查框排列方向
    switch ( cborepeatdirection . selectedindex)
    {
     case 0 :
      chklist . repeatdirection = repeatdirection . vertical ;
      break ;
     case 1 :
      chklist . repeatdirection = repeatdirection . horizontal ;
      break ;
    }
  
    //組件中各個檢查框的排列行數
    try
    {
     int cols = int . parse ( txtrepeatcols.text ) ;
     chklist . repeatcolumns = cols ;
    }
    catch ( exception )
    {
    }
  
    lblresult . text = "" ;
    for ( int i = 0 ; i < chklist . items . count ; i++ )
    {
     if( chklist . items [ i ] . selected )
     {
      lblresult . text += chklist . items [ i ] .text + " <br > " ;
     }
    }
   }
   </script >
   </head >
   <body >
   <form runat = "server" >
    <h1 align = center > checkboxlist組件演示程序 </h1 >
    <table >
     <tr >
      <td > 組件中的文本排列位置: </td >
      <td >
        <asp:dropdownlist id = cboalign runat = "server" >
         <asp:listitem > 居左 </asp:listitem >
         <asp:listitem > 居右 </asp:listitem >
        </asp:dropdownlist >
      </td >
     </tr >
     <tr >
      <td > 組件中各個條目布局: </td >
      <td >
        <asp:dropdownlist id = cborepeatlayout runat = "server" >
         <asp:listitem > 表格型 </asp:listitem >
         <asp:listitem > 緊湊型 </asp:listitem >
        </asp:dropdownlist >
      </td >
     </tr >
     <tr >
      <td> 組件中各個條目排列方向:</td >
      <td >
        <asp:dropdownlist id = cborepeatdirection runat = "server" >
         <asp:listitem > 水平方向 </asp:listitem >
         <asp:listitem > 垂直方向 </asp:listitem >
        </asp:dropdownlist >
      </td >
     </tr >
     <tr >
      <td > 組件中各個條目排列行數: </td >
      <td > <asp:textbox id = "txtrepeatcols" runat = "server" /> </td >
     </tr >
    </table >
    <br >
     請選擇你所需要學習的計算機語言類型:
    <br >
    <asp:checkboxlist id = "chklist" repeatdirection = horizontal runat = "server" >
     <asp:listitem > visual c++ .net </asp:listitem >
     <asp:listitem > visual c# </asp:listitem >
     <asp:listitem > vb.net </asp:listitem >
     <asp:listitem > jscript.net </asp:listitem >
     <asp:listitem > visual j# </asp:listitem >
    </asp:checkboxlist >
    <br >
     <asp:button text = "提交" runat = "server" onclick = "button_click" />
     <h1 > <font color = red > 你選擇的計算機語言類型為: </font > </h1 >
     <asp:label id = lblresult runat = "server" />
   </form >
   </body >
  </html >
  
  
    六. 總結:
  
    其實checkboxlist組件也是一個服務器端組件。本文介紹了checkboxlist組件中的一些主要的屬性和方法,并且通過一個比較典型的例子說明了在asp.net頁面中如何進行與checkboxlist組件相關的編程,其實對于另外一個比較重要的組件--checkbox來說,他們中有許多的相似之處,掌握了checkboxlist組件的用法大致也就掌握了checkbox組件的用法。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 琼中| 新源县| 玉龙| 乌拉特后旗| 永吉县| 响水县| 深州市| 潼关县| 民县| 阜平县| 乌拉特后旗| 调兵山市| 叶城县| 铜山县| 南皮县| 小金县| 广灵县| 昭觉县| 邮箱| 敖汉旗| 洪洞县| 湖州市| 赞皇县| 安仁县| 洮南市| 阿拉善右旗| 讷河市| 长寿区| 辽中县| 安达市| 崇阳县| 仲巴县| 定西市| 深泽县| 紫阳县| 连山| 萍乡市| 正镶白旗| 巴南区| 云南省| 策勒县|