How to persist a dynamic control (c#)

前端 未结 4 1051
北荒
北荒 2021-01-16 06:15

As per the title, I have created a custom control.

On a certain button click event, this control is instantiated, then added to the page.

It is a dynamic con

4条回答
  •  时光说笑
    2021-01-16 06:43

    As with all HTML pages, the control must be recreated on each page request. ASP.NET handles a lot of this 'under the hood' with mechanisms such as ViewState and Session.

    If your control is not (or can't be) tracked by ViewState, then you need to handle this yourself.

    I don't know how complex your control is, but as a starting point you may wish to read up on handling the CreateChildControls event here (MSDN)

提交回复
热议问题