动态将控件添加到ASPX页面
你好,
我有一个aspx页面.最初它将具有以下控件.
5个标签,3个文本框,2个下拉框,
3个按钮.
我的按钮之一是"ADD".
单击``添加''按钮时要完成的功能是添加另一组相同的控件,即5个标签,3个文本框,2个具有不同ID的下拉框.
以前的控件应保留在页面中.有了它们,应动态添加相同的控件.
如果需要将以上控件添加超过20次,则用户可以按下"ADD"按钮20次以上
请帮助动态添加这些控件,以及如何处理它们并从这些新控件中检索值.
请不要介意我的英语不好.
谢谢.
Hello,
I am having an aspx page. It initially will have the following controls.
5 lables, 3 text boxes, 2 dropdown boxes,
3 buttons.
One of my button is ''ADD''.
The function to be done on click of the ''ADD'' button is to add another set of same controls , i.e., 5 lables, 3 text boxes, 2 dropdown boxes with different IDs.
The previous controls should remain in the page.With them , same controls should be added dynamically.
User can press the ''ADD'' button more than 20 times if needed to add the above controls more than 20 times
Kindly help with adding these controls dynamically and how to handle them and retrieve values from these new controls.
Please dont mind my bad english.
Thanks.
您可以随意添加它们.但是,除非您创建一种机制来使用隐藏的控件来跟踪它们,这些隐式控件包含告诉您如何重新创建它们的值,否则它们将不会在回发时还原.动态创建的控件没有viewstate.这基本上是一个坏主意.最好的方法是使所有动作都通过jquery使用AJAX进行,这样就无需回发,也无需重新创建控件.
You can add them as often as you like. However, they will not be restored on a postback unless you create a mechanism to track them using a hidden control to contain values telling you how to recreate them. There is no viewstate for dynamically created controls. It''s basically a bad idea. The best way to do this is to make all your actions occur using AJAX with jquery, that way there''s no postback and no need to recreate the controls.