动态创建Div元素

动态创建Div元素

问题描述:





我有一个要求,我必须在点击按钮时动态创建一个Div。



Div将有一些其他子div和控件。为此我已经为整个div创建了一个用户控件,我将它添加到面板。



现在我的实际需求是用户点击按钮div(Usercontrol)应该创建单击按钮的次数。创建的div应该保存,以后如果我打开页面动态添加Div应该显示。



同样删除也是。



代码后面的代码会发生。



如果有人知道它,请帮助我。





提前致谢



Midhun Bezawada

Hi,

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

Hi Midhun,



现在如果你通过jquery / JavaScript在客户端添加控件然后调用webmethod并保存控制状态,如果在服务器上然后也就是在添加div之后,调用一个方法来保存控件状态。如有任何问题,请更新我。
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.