日期:2014-05-17  浏览次数:20466 次

B/S 一些CheckBox控件 Button提交时判断CheckBox选中状态checked属性

我用图片展示出了页面的效果


我希望实现的功能是 判断页面上的 CheckBox控件上的属性 checked 

Button导出数据事件 时先判断至少1个CheckBox是选中状态 并提示

javascript或者jquery 或者 后台代码实现也行!

前台代码如下
C# code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SWDataMonitorExport.aspx.cs" Inherits="CTWebPlatform.DataMonitoring.SWDataMonitorExport" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>导出数据</title>
     <link href="../Styles/Site.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
    function unselectall() {
        if (document.myform.chkAll.checked) {
            document.myform.chkAll.checked = document.myform.chkAll.checked & 0;
        }
    }
    function CheckAll(form) {
        for (var i = 0; i < form.elements.length; i++) {
            var e = form.elements[i];
            if (e.Name != 'chkAll' && e.disabled == false)
            { e.checked = form.chkAll.checked; }
        }
    }
 </script>
</head>


<body>
    <form id="form1" runat="server">

    <div style="background-color:White;">   
    <br />  
       <table width="100%" class="style-table">
<tr>
                 <td class="style1">
                <div class="style-saearch">
                 <div class="search2to">
                 <table border="0" cellpadding="0" cellspacing="0" class="Table_Search">
                             <tr>
                                 <td>
                                     <span class="MarginLeft10">
                                     
                                     
                                     </span>
                                     <asp:RadioButton ID="RadioExcel" runat="server" Text="Microsoft Excel 工作表" 
                                      GroupName="Export" Checked="True" />
                                 </td>
                                 <td >
                                   
                                     <asp:RadioButton ID="RadioWord" runat="server" Text="Microsoft Word 文档" 
                                         GroupName="Export" />
                                   
                                 </td>
                                 <td>
                                    
                                     <asp:RadioButton ID="RadioTXT" runat="server" Text="超文本网页 Html" 
                                         GroupName="Export" />
                                    
                                 </td>
                                 <td>在线浏览&nbsp;
                                     
                                     </td>
                                 <td>
                                    
                                     &nbsp;</td>
                                 <td >
                                     
                               <asp:Button ID="ButtonHTTP" runat="server" CssClass="Button02" Height="24px" 
                                         Text="将数据导出" Wid