Showing posts with label Dynamic Controls. Show all posts
Showing posts with label Dynamic Controls. Show all posts

Thursday, April 23, 2009

Creating Dynamic Controls, and Preserve them for alternate Page Loads : ASP.NET

Normally when you create a control dynamically means at runtime, on the next page load you will loose that control, that control will be no longer exists, in this example I am try to explain how we can store that controls and get them back.

Create a Web Application and Add one button to it.
In the page load add following code, in the following code I am creating a object of Control Collection and keeping it in the Session.

image

Now Doble click on button1 and add following code in Button1_Click event.
Here in this code I am storing all the controls created into control collection and saving into session.

image

now we are ready with code just build, run and test.

Tags: Creating Dynamic controls, ASP.NET, C#, Preserve the Dynamic controls