using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
Label mylabel = new Label();
Button mybutton = new Button();
protected void Page_Load(object sender, EventArgs e)
{
mylabel.Text = "hello";
mybutton.Text = "then";
PlaceHolder1.Controls.Add(mylabel);
PlaceHolder1.Controls.Add(mybutton);
}
protected void Button1_Click(object sender, EventArgs e)
{
PlaceHolder1.Controls.Remove(mylabel);
PlaceHolder1.Controls.Remove(mybutton);
Label mylabel1 = new Label(); // This is new control replaces that old controls
mylabel1.Text = "hi";
PlaceHolder1.Controls.Add(mylabel1);
}
}