且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将控件添加到表控制动态

更新时间:2023-11-30 22:37:22

在添加控件动态,如果你想访问他们在回发,则需要重新创建它们的每次的页面是加载。

When adding controls dynamically, if you want to access them on postback, you need to re-create them every time the page is loaded.

在一个按钮的点击处理程序添加他们,期待他们在那里为其他按钮将无法正常工作的点击处理程序,因为他们没有第二回传重新创建。

Adding them in the click handler of one button and expecting them to be there for the click handler of another button will not work, as they have not been re-created on the second postback.

您需要了解 asp.net页面生命周期和改变你的网页以配合它的逻辑。

You need to understand the asp.net page life cycle and change the logic of your page to fit in with it.