帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > ASP.NET编程 >
ASP.NET中WebForm组件CheckBoxList编程(4)
作者:马金虎 发布时间:2005-03-12 来源:ASPCOOL
     五. 文中源程序代码(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组件的用法。
  

  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·ASP.NET Authentication Provide  (2005-03-12)
 ·ASP.NET画图全攻略(下)  (2005-03-12)
 ·ASP.NET画图全攻略(上)  (2005-03-12)
 ·ASP.NET计数器  (2005-03-12)
 ·ASP.NET虚拟主机的重大安全隐患(  (2005-03-12)
 ·ASP.NET虚拟主机的重大安全隐患(  (2005-03-12)
 ·ASP.NET虚拟主机的重大安全隐患(  (2005-03-12)
 ·ASP.NET虚拟主机的重大安全隐患(  (2005-03-12)
 ·ASP.NET虚拟主机的重大安全隐患(  (2005-03-12)
 ·ASP.NET虚拟主机的重大安全隐患(  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·放眼未来 帝国近期将有重大举措!
·PHPWind6.3.2版通行证发布
·帝国备份王2008版正式发布
·帝国备份王2008版发布
·phpcms2007转帝国CMS5.0程序发布
·dedecms5.1转帝国CMS5.0程序发布
·帝国网站管理系统V5.0商业购买说明
   类别最新
·ASP.NET中为DataGrid添加合计字段
·.text urlRewrite介绍
·利用 ASP.NET 的内置功能抵御 Web
·ASP.NET Cache
·用 WebClient.UploadData 方法 上载
·ASP.NET 程序设计-序
·什么是客户端/伺服端(Client/Serve
·因特网应用程序的开发
·网页的种类
·.NET Framework-Microsoft Visual
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统