Maintain the state of dynamically added user control on postback?

前端 未结 4 2226
醉酒成梦
醉酒成梦 2020-12-06 20:31

I have a user control that contains only a text box and on another form I add this user control dynamically, a user can add the user control many times. I use a session vari

4条回答
  •  萌比男神i
    2020-12-06 21:25

    I've had the same problem in the past.

    What I did was give the dynamically-added control an ID, and made sure it retained that ID also on postback (in my case, I kept all the information in the session, and re-created the controls).

    Once the postbacked control has the same ID as as before, Microsoft did magic and refilled the controls with the pre-postback values.

提交回复
热议问题