62,254
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnSelWeiHu" runat="server" Text="Button" OnClick="btnSelWeiHu_Click" OnClientClick="return Check();" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:RadioButtonList ID="RadioButtonList2" runat="server">
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
</asp:RadioButtonList>
<script type="text/javascript">
function Check() {
var rd = document.getElementById("<%=RadioButtonList2.ClientID %>");
var len = rd.rows.length;
for (var i = 0; i < len; i++) {
var ss = rd.id + "_" + i;
var aa = document.getElementById(ss).value;
var bb = document.getElementById(ss);
if (aa == 3 && document.getElementById(ss).checked) //注意checked不能写成Checked,要不然不成功
{
return confirm("范围选择为全部,可能数据量较大会影响速度,您确定查询吗?");
}
}
return true;
}
</script>
</form>
</body>
</html>
protected void btnSelWeiHu_Click(object sender, EventArgs e)
{
if (this.RadioButtonList2.SelectedValue == "1")
{
//...选择1时执行部分
}
else if (this.RadioButtonList2.SelectedValue == "2")
{
//....选择2时执行部分
}
else
{
//选择3执行的部分
}
}
protected void Page_Load(object sender, EventArgs e)
{
btnSelect.OnClientClick = "if(document.getElementById('"+RadioButtonList1.ClientID+"'+'_2').checked){return confirm('OK');}";
}'_2',是对应你的Radio所在索引,如果是第三个就是2,第四个就是3,索引从零开始