Hi this is Kiran kumar

How the Controls that are created dynamically in the page load will maintain their
state that means how they will preserve the values .

if anybody knows the answer please help me

thanks in advancce
regards kiran kumar

Recommended Answers

All 2 Replies

Sample.aspx

<form id="form1" runat="server">
    <div>
    
    </div>
    </form>

Sample.aspx.cs

protected void Page_Load(object sender, EventArgs e)
    {
        TextBox tx = new TextBox();
        tx.ID = "txt1";
        form1.Controls.Add(tx);
        Button b1 = new Button();
        b1.ID = "btn1";
        form1.Controls.Add(b1);
        b1.Click += (s, args) =>
        {
            TextBox t = (TextBox)FindControl("txt1");
            Response.Write(t.Text);
        };
    }

Read ASP.NET Page life cycle article - http://msdn.microsoft.com/en-us/library/ms178472.aspx

yaa i understood your code . but i want where exactly the state will be retained in
the asp.net page life cycle.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.