获取动态生成checkbox的id
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="No.aspx.cs" Inherits="Guest_No"
Title="" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:DropDownList ID="Year" runat="server">
<asp:ListItem Value="0">请选择年</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2013</asp:ListItem>
<asp:ListItem>2014</asp:ListItem>
<asp:ListItem>2015</asp:ListItem>
<asp:ListItem>2016</asp:ListItem>
<asp:ListItem>2017</asp:ListItem>
<asp:ListItem>2018</asp:ListItem>
<asp:ListItem>2019</asp:ListItem>
<asp:ListItem>2020</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="Month" runat="server">
<asp:ListItem Value="0">请选择月</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<div runat="server" id="div1" visible="false">
<asp:Table ID="Table1" runat="server" BorderColor="Black" BorderWidth="1px" GridLines="Both">
</asp:Table>
<asp:Button ID="Button2" runat="server" Text="提交" OnClick="Button2_Click" /><asp:Button
ID="Button3" runat="server" Text="重置" />
</div>
</asp:Content>
protected void Button1_Click(object sender, EventArgs e)
{
int i, j, k;
int year = Convert.ToInt32(Year.SelectedValue.ToString());
int month = Convert.ToInt32(Month.SelectedValue.ToString());
if (year.ToString() == "0" || month.ToString() == "0")
{
Label1.Text = "请选择年月";
}
else if (year.ToString() == "0")
{
Label1.Text = "请选择年";
}
else if (month.ToString() == "0")
{
Label1.Text = "请选择月";
}
else
{
int day = Convert.ToInt32(DateTime.DaysInMonth(year, month).ToString());
DateTime firstDay = new DateTime(year, month, 1);
DateTime lostDay = new DateTime(year, month, DateTime.DaysInMonth(year, month));
TableRow tRow1 = new TableRow();
Table1.Rows.Add(tRow1);
TableCell Cell1 = new TableCell();
Cell1.Text = "号";
tRow1.Cells.Add(Cell1);
for (i = 1; i <= day; i++)
{
TableCell tCell1 = new TableCell();
tCell1.Text = i.ToString();
tRow1.Cells.Add(tCell1);
}
TableRow tRow2 = new TableRow();
Table1.Rows.Add(tRow2);
TableCell Cell2 = new TableCell();
Cell2.Text = "1,2";
tRow2.Cells.Add(Cell2);
for (i = 1; i <= day; i++)
{
TableCell tCell2 = new TableCell();
tRow2.Cells.Add(tCell2);
CheckBox CB = new CheckBox();
CB.ID = "cb1" + i.ToString();
tCell2.Controls.Add(CB);
}
}怎么获取checkbox的id,使用了母板页,这是内容页
...全文
相关推荐
C#获取动态生成的CheckBox值
checkbox是VS2012的常用控件之一,可以方便的为某些功能取消或启用,下面教你如何简单使用checkbox。本文通过两种方法给大家介绍,需要的朋友一起看看吧
Vue动态生成el-checkbox点击无法赋值的解决方法
前言 最近遇到一个问题,在一个页面需要动态渲染页面内的表单,其中包括 checkbox 表单类型,并且使用 Element 组件 UI 时,此时 v-model 绑定的数据也是动态生成的 例如: 定义的 data 的 form 里面是空对象,需要动态生成里面的 key export default { data() { return { form: {} } }, } 从后端接口得到 checkList,这个就是动态生成的表单数据 v-for 循环 checkList,得到 key,然后直接 v-model=“form.key” 动态生成 form 里面的 key <el-
jquery之checkbox操作(v1.0.0)
jquery动态生成checkbox 设置一行最多显示几个checkbox 获取checkbox选中项
本示例实现利用 XML 布局文件动态创建CheckBox
本示例实现利用 XML 布局文件动态创建CheckBox 可以在XML布局文件中先配置一个或若干CheckBox,然后以这些配置为模板来动态创建CheckBox对象
CheckBox多选功能的实现
CheckBox多选功能的实现 ListView与CheckBox CheckBox多选功能的实现 ListView与CheckBox


