Dynamically added controls in Asp.Net

后端 未结 9 1662
情书的邮戳
情书的邮戳 2020-12-01 02:22

I\'m trying to wrap my head around asp.net. I have a background as a long time php developer, but I\'m now facing the task of learning asp.net and I\'m having some trouble w

9条回答
  •  我在风中等你
    2020-12-01 03:00

    I ran across this in the book "Pro ASP.NET 3.5 in C# 2008" under the section Dynamic Control Creation:

    If you need to re-create a control multiple times, you should perform the control creation in the Page.Load event handler. This has the additional benefit of allowing you to use view state with your dynamic control. Even though view state is normally restored before the Page.Load event, if you create a control in the handler for the Page.Load event, ASP.NET will apply any view state information that it has after the Page.Load event handler ends. This process is automatic.

    I have not tested this, but you might look into it.

提交回复
热议问题