How to add textbox control on button click event?
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{   
     
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Session["Count"] = 1;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int count = 0;
        int i=0;
        count = Convert.ToInt32(Session["Count"]);
        for(i=0;i<count;i++)
        {
            TextBox  txt = new TextBox();
        txt.ID = "txt" + count;
      
        PlaceHolder1.Controls.Add(txt);
        }
        Session["Count"] =Convert.ToString(Convert.ToInt32(Session["Count"].ToString()) + 1);
    }
}
Comments
Post a Comment