Accessing dynamically created textboxes text

前端 未结 1 543
囚心锁ツ
囚心锁ツ 2021-01-23 05:17

I have stumbled across a problem with my asp.net form.

Within my form the end user chooses a number of textboxes to be dynamically created, this all works fine

相关标签:
1条回答
  • 2021-01-23 05:49

    The issue is these text boxes need recreated in the Load event of the page, every single time, so that both events and values can be hooked back up and retrieved.

    I think the most straight forward approach, in your case, would be to extend idea #1 that you had already tried. Build a List of these controls with enough information to recreate them in Load, but you need to store that List in either ViewState or Session.

    ViewState["DynamicControls"] = list;
    

    or

    Session["DynamicControls"] = list;
    

    I would use ViewState if you can because it gets destroyed when the user leaves the page.

    0 讨论(0)
提交回复
热议问题