Save programmatically created html controls after postback

I add HTML input controls to the page dynamically using the "add text box" button, but after sending the message, they are eventually washed off. Is there an easy and effective practice that can help me save the controls and their values ​​after sending the page back.

Thanks.

Edit:

  • I use Javascript to create dynamic controls on the page
  • I do not upload files just by creating custom fields.

I think I need to override the SaveViewState and LoadViewState events in order to save the controls in the ViewState.

+5
source share
4 answers

See the following:
http://urenjoy.blogspot.com/2009/02/add-dynamic-buttons-and-handle-click.html
You need to override the SaveViewState and LoadViewState methods to save after the postback, see the following
http: / /urenjoy.blogspot.com/2009/03/create-dynamic-dropdownlists-in-aspnet.html
and for a value see the following example:
http://urenjoy.blogspot.com/2009/02/retrieve-value-of -dynamic-controls-in.html

+2
source

Hold the page! Use ajax to publish data and the Flash loader if you are dealing with file downloads. Then the page never refreshes, and there is much less code to re-create dynamically created controls.

+2

since you will receive them in the response message, could you dynamically recreate them server-side?

0
source

If the controls are different from postback to postbck depending on what the user enters, you can try to save the html ito in a separate class where you will have static properties like public static string WriteHTMLSubmit = ""

If not, then hardcode them in the code behind, it will be a practice ... if(page.isPostBack){<write contrls>}

0
source

All Articles