我創建一個按鈕,將它添加到面板有毛病我的ASP按鈕,同時將其添加到面板.. ASP和C#
Panel p = new Panel();
p.ID = "b_con";
p.Attributes.Add("runat", "server");
this.Controls.Add(p);
Button b = new Button();
b.Attributes.Add("value", "reply");
b.Attributes.Add("id", Convert.ToInt32(r["Message_ID"]).ToString());
b.Attributes.Add("class", "button");
b.Click += new System.EventHandler(button_Click);
p.Controls.Add(b);
我得到這個錯誤類型的 控制「ctl01」 'Button'必須放置在runat = server的表單標籤中。
面板是服務器控件。你不需要添加'runat =「server」'。一個Button有一個「Id」和一個「Text」屬性。 –
在什麼時候將面板添加到頁面? –
你的問題解決了嗎? –