Ajax "Update Panel" control error
-
I have a error in learning Ajax lessons. The error is "UpdatePanel does not contain a definition for ContentTemplateContainer". Following is my codes: public partial class UpdatePanel1 : System.Web.UI.Page { private Label label1; protected void Page_Load(object sender, EventArgs e) { UpdatePanel l_UpdatePanel = new UpdatePanel(); l_UpdatePanel.ID = "UpdatePanel1"; //Create the label label1 = new Label(); label1.ID = "Label1"; label1.Text = DateTime.Now.ToString(); //Create the button Button l_Button = new Button(); l_Button.ID = "Button1"; l_Button.Click += new EventHandler(l_Button_Click); //Create the literals LiteralControl l_LiteralControl = new LiteralControl(); //Embed the controls to the UpdatePanel l_UpdatePanel.ContentTemplateContainer.Controls.Add(label1); l_UpdatePanel.ContentTemplateContainer.Controls.Add(l_LiteralControl); l_UpdatePanel.ContentTemplateContainer.Controls.Add(l_Button); //Add the update panel to the form this.Controls.Add(l_UpdatePanel); } void l_Button_Click(object sender, EventArgs e) { this.label1.Text = DateTime.Now.ToString(); } }
-
I have a error in learning Ajax lessons. The error is "UpdatePanel does not contain a definition for ContentTemplateContainer". Following is my codes: public partial class UpdatePanel1 : System.Web.UI.Page { private Label label1; protected void Page_Load(object sender, EventArgs e) { UpdatePanel l_UpdatePanel = new UpdatePanel(); l_UpdatePanel.ID = "UpdatePanel1"; //Create the label label1 = new Label(); label1.ID = "Label1"; label1.Text = DateTime.Now.ToString(); //Create the button Button l_Button = new Button(); l_Button.ID = "Button1"; l_Button.Click += new EventHandler(l_Button_Click); //Create the literals LiteralControl l_LiteralControl = new LiteralControl(); //Embed the controls to the UpdatePanel l_UpdatePanel.ContentTemplateContainer.Controls.Add(label1); l_UpdatePanel.ContentTemplateContainer.Controls.Add(l_LiteralControl); l_UpdatePanel.ContentTemplateContainer.Controls.Add(l_Button); //Add the update panel to the form this.Controls.Add(l_UpdatePanel); } void l_Button_Click(object sender, EventArgs e) { this.label1.Text = DateTime.Now.ToString(); } }
You need to check this before doing a single line of code : http://forums.asp.net/t/982600.aspx[^] You need to create
CompiledTemplateBuilder
to access ContentTemplateContainer. :)Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript