Persisting Dynamically added controls even after refresh [Resolved]

Posted by Prabhukiran345 under C# on 2/5/2014 | Points: 10 | Views : 566 | Status : [Member] | Replies : 2
Hi,

I have added some controls dynamically in code behind. Now i want to to persist them even after page reload. Is it possible? If Yes , how to achieve it.

regards,
Prabhu Kiran B

Thanks,
Prabhu Kiran Bommareddy



Responses

Posted by: Sravan661 on: 2/5/2014 [Member] Bronze | Points: 50

Up
0
Down

Resolved
you need to reload your dynamic controls on each and every postback - by the page_load event at the latest
Hope it helps you

sravan

Prabhukiran345, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sravan661 on: 2/5/2014 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Capture your TextBox value in post box as follow
 ViewState["txtvalue"] = ((TextBox)Form.FindControl("txt1")).Text;

Add the text box dynamically as follows
TextBox t = new TextBox();
t.ID = "txt1";
t.Text = ReferenceEquals(ViewState["txtvalue"], null) ? "" : Convert.ToString(ViewState["txtvalue"]);
Form.Controls.Add(t);


sravan

Prabhukiran345, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response