I am adding Asp:Button Controls in C# code behind. But when page loads in Browser, button doesn't appear on page. Here is my piece of code
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() });
You can only append html inputs as buttons dynamically. ASP.Net components compile and get translated to html. The browser doesn't understand this part of your code:
<asp:Button ID='btnAdd' runat='server' OnClick='BtnAddStd_Click' Text='Add' />