【发布时间】:2016-01-08 07:34:47
【问题描述】:
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_load 中为文本框设置任何 id
-
我使用 jquery 来查看文本框的 ID。每个文本框都有一个唯一 ID,例如 texttbox11、textbox12 等
标签: c#