I am creating buttons and add them to a table that i want to add onto a page:
void MyButtonTable()
{
TableRow myTableRow = new TableRow();
foreach (var item in buttons)
{
TableCell myTableCell = new TableCell();
myTableCell.Controls.Add(item);
myTableRow.Cells.Add(myTableCell);
}
HtmlForm html = new HtmlForm();
Table2.Rows.Add(myTableRow);
Table2.BorderWidth = 1;
Table2.BorderColor = System.Drawing.Color.Black;
html.Controls.Add(Table2);
Page.Controls.Add(html);
}
I need to add it through htmlForm and add it to the page..instead of adding the table straight to the page..
(i get Control ‘ctl02’ of type ‘Button’ must be placed inside a form tag with runat=server.)
but when i add html, i want to cancel the run at attribute..to prevent this exception from being generated:
A page can have only one server-side Form tag
You need to add the table inside the existing
<form runat="server">.As the error message states, you cannot have to server-side
<form>s.