该页面在 updatePanel 内有表格,在 tablecell 内有链接按钮:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Table ID="Table1" runat="server" BackColor="White" BorderColor="Black"
BorderWidth="1px" ForeColor="Black" GridLines="Both" BorderStyle="Solid">
</asp:Table>
</ContentTemplate>
</asp:UpdatePanel>
在 .cs 文件中,我将行添加到表中:
TableRow tr = new TableRow();
TableCell tc = new TableCell();
LinkButton lb = new LinkButton();
lb.Text = "Click me";
lb.Click += new EventHandler(this.LinkButton_Click);
tc.Controls.Add(lb);
tr.Cells.Add(tc);
Table1.Rows.Add(tr);
和方法:
protected void LinkButton_Click(Object sender, EventArgs e)
{
Response.Write("<script type='text/javascript'>");
Response.Write("alert('Ok!');");
Response.Write("</script>");
}
因此,当我单击链接按钮时,警报不起作用。什么是问题?
请注意,如果我删除更新面板,则链接按钮在单击它时会起作用。