Le contrôle "ctl02" de type "Bouton" doit être placé à l'intérieur d'une balise de formulaire avec runat=server

Je reçois cette erreur lorsque vous essayez de générer un certain nombre de boutons de la programmation. Je n'ai pas de ctl02.. Pourquoi suis-je une erreur?

  Button pgs = new Button();//Create New Topic
                        pgs.Width = 20;                        
                        pgs.Command += obtainTopicsPerPage_Click;
                        pgs.CommandName = tPage.ToString();
                        pgs.Text = tPage.ToString();

                        btns.Add(tPage.ToString());
                        buttons.Add(pgs);

J'ai créer quelques boutons et boucle le long de la liste (les boutons). Puis-je obtenir cette erreur :(. ... pourquoi?

Complet de conception:

int maximumTopicPages;
int tPage;
int questionNumber=1;
Dictionary<string, List<DisplayAllQuestionsTable>> tPages;
List<Button> buttons = new List<Button>();
protected void Answer_Click(object sender, EventArgs e)
{
ViewState["SeekPressed"] = "pressed";
tPages = new Dictionary<string, List<DisplayAllQuestionsTable>>();
string subTopic = SubTopicDropDownList.SelectedItem.Value;
List<DisplayAllQuestionsTable> threadsByTopic = new List<DisplayAllQuestionsTable>();
List<string> btns = new List<string>();
foreach (var topicKeys in postsByTopic)
{
if (topicKeys.Key == subTopic)
{
foreach (var item in postsByTopic[topicKeys.Key])
{
questionNumber++;
maximumTopicPages++;
threadsByTopic.Add(item);//Adds All DisplayAllTables objects
//if there are 20 add a button.
if (maximumTopicPages == 20)
{
tPages.Add(tPage++.ToString(), threadsByTopic);//Add a number to the page each time, with a DisplayTable object  
//new Button
Button pgs = new Button();//Create New Topic
pgs.Width = 20;                        
pgs.Command += obtainTopicsPerPage_Click;
pgs.CommandName = tPage.ToString();
pgs.Text = tPage.ToString();
btns.Add(tPage.ToString());
buttons.Add(pgs);
maximumTopicPages = 0;
threadsByTopic.Clear();
}
}//number of questions per page
if (!tPages.ContainsKey((questionNumber / 20).ToString()))
{
tPages.Add((questionNumber / 20).ToString(), threadsByTopic);//If A button is missing add it.
}
} 

Façon, les boutons sont ajoutés à la table:

    void MyButtonTable()
{
TableRow myTableRow = new TableRow();
HtmlForm form = new HtmlForm();
form.Attributes.Add("runat", "server");
Page.Controls.Add(form);
foreach (var item in buttons)
{
TableCell myTableCell = new TableCell();
form.Controls.Add(item);
myTableCell.Controls.Add(item);
myTableRow.Cells.Add(myTableCell);
}
Table2.Rows.Add(myTableRow);
Page.Controls.Add(Table2);
}
  • Qu'est-ce que les boutons ? merci de poster votre conception de formulaire ?
  • C'est une simple Liste. voir ci-dessus
InformationsquelleAutor Matrix001 | 2011-06-14