I came across a problem when I need to cancel html controls. I added the client part using JavaScript after the postback (due to server-side validation - this is optional).
Please tell me the way I'm trying to achieve this is cr * p, and there is the best way to do this.
basically, what I do is clone the text box control up to 10 times on the page when the user clicks “Add” and saves the entered values from each of these text boxes in a hidden field for reading from the code. This works fine, however when the server-side check fails after the postback, all those dynamically added (cloned) text boxes disappear, because ViewState knows nothing about them.
I am considering 2 possible solutions, both of which seem to be hacked:
Recover all cloned text fields in onload () document using stored values in a hidden field
wrap the form in the ajax update panel and place the cloned tex boxes outside of it, thus not updating this part of the screen during postback
Now, is it possible to somehow “update” the ViewState so that it knows about all the html controls that I added using the client side of the script? Any better ideas? I would like to achieve this on the client side of the script, so without considering the cloning of text fields on the server side, sorry.
source
share