Click here to Skip to main content
15,797,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have a requirement where i have to create a Div dynamically on button click.

The Div will have some other child div and controls in them. For that i have created a User control for whole div and i am adding it to a panel.

Now my actual requirement is when user clicks on button div(Usercontrol) should get created the number of times button is clicked. created div's should be saved and later if i open the page dynamically added Div's should be displayed.

The same with deleting also.

The code thing should happen from code behind.

If any one have idea of it please help me.

Thanks in advance

Midhun Bezawada
Updated 3-Apr-14 19:32pm

1 solution

Hi Midhun,

Now if you are adding controls on Client side by jquery/JavaScript then call a webmethod and save the control state else if on server side then also just after adding the div, call a method to save the control state. In case any issue, please update me.
Share this answer
midhun3600 4-Apr-14 1:08am    
How can i save control state could you please explain, because control once added should be added permanently.
midhun3600 4-Apr-14 1:09am    
i want to save the whole control(user control) it-self.
Er. Puneet Goel 4-Apr-14 1:31am    
ok, can you explain bit more like what you actually wanted to implement?
midhun3600 4-Apr-14 2:24am    
i wanted to add a user control.In that user control i kept all the div element and controls i needed.

Now from my front end i have a textbox to have a title for that user control.
when user enters text and clicks on button,user control should be added to page for that particular user permanently.
if user logout and logs in again user control added before should be like that only.

likewise i can add any no.of controls to page for a particular user.
i can achieve this statically by adding them in markup but i want to make it dynamic.
Er. Puneet Goel 4-Apr-14 2:28am    
yes you can do this, you can have a table with UserControl in database and you can save the value that user has added the control. Now if user added two control save the value to 2. But if you have more info to save please provide the code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900