0

我在后面的 C# 代码中添加 Asp:Button Controls。但是当页面在浏览器中加载时,按钮不会出现在页面上。这是我的一段代码

    html.Append("<table>");
    html.Append("<tr><th>Student Name</th><th>Operations</th>");

    while (msdr.Read())
    {
        html.Append("<tr>");
        html.Append("<td>" + msdr[0] + "</td>");
        html.Append("<td align='center'><asp:Button ID='btnAdd' runat='server' OnClick='BtnAddStd_Click' Text='Add' /></td>");
        html.Append("</tr>");
     }
      html.Append("</table>");
      Placeholder1.Controls.Add(new Literal { Text = html.ToString() });
4

1 回答 1

0

您只能动态地将 html 输入附加为按钮。ASP.Net 组件编译并翻译成 html。浏览器不理解这部分代码:

<asp:Button ID='btnAdd' runat='server' OnClick='BtnAddStd_Click' Text='Add' />

于 2016-02-22T06:53:53.370 回答