检查按钮事件处理程序是否没有执行所需的功能
本文关键字:执行 功能 按钮 事件处理 程序 是否 检查 | 更新日期: 2023-09-27 17:54:40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class product_entry : System.Web.UI.Page
{
int count;
protected void Page_Load(object sender, EventArgs e)
{
int i, j;
for (i = 0; i < 1; i++)
{
TableRow tr = new TableRow();
tr.Attributes.Add("class", "tabrow");
for (j = 0; j <= 8; j++)
{
TableCell tc = new TableCell();
if (j == 0)
{
tc.Controls.Add(new LiteralControl("<Button class=remove type=button>-</button>"));
}
if (j == 1)
{
tc.Attributes.Add("class", "sno");
}
if (j == 2 || j == 3 || j == 4 || j == 5 || j == 6 || j == 7 || j == 8)
{
TextBox tb = new TextBox();
tb.Style["width"] = "98%";
tc.Controls.Add(tb);
}
tr.Controls.Add(tc);
}
Table1.Controls.Add(tr);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Label2.Text = TextBox1.Text;
for (int i = 1; i <= count; i++)
{
for (int j = 1; j <= 7; j++)
{
TextBox aa = (TextBox)Pnl.FindControl("textbox" + i + j);
Response.Write(aa.Text);
}
}
}
}
我试图获得文本框的值,我在页面加载上动态生成并克隆它们使用jquery....
每个文本框都有一个矩阵形式的唯一id,例如第一行的文本框有id textbox11,textbox12,textbox13,textbox14等行textbox21,textbox22,textbox23........
有没有办法得到值…而且,循环int按钮事件处理程序没有执行其任务
protected void Button1_Click(object sender, EventArgs e)
{ TextBox aa = (TextBox)Pnl.FindControl("textbox22");
Label2.Text = aa.Text;}
我试着检查结果,但它给出错误
尝试在Page_PreInit
方法中创建动态文本框
protected void Page_PreInit(object sender, EventArgs e)
{
TextBox tb = new TextBox();
tb.ID = "textBox";
tb.Text = "";
Panel1.Controls.Add(tb);
}