Reputation: 26167
How can I retain client side html controls on postback? I have tried setting enableviewstate="true"
but that did not work. A workaround I've done was to build a server side function that takes all the posted values and resets them via ClientScript.RegisterStartupScript
and call this on every postback method. Is there an easier and more time efficient way of doing this?
Upvotes: 2
Views: 2573
Reputation: 46047
You need to create the controls at every postback. If you're looking for something a little easier to implement, take a look at the DynamicControlsPlaceholder control. It's a nifty little control that takes away most of the pain associated with persisting dynamic content.
Upvotes: 1
Reputation: 1076
Can you use HiddenField?
Now on clicking any button at client side, Preserve the data in HiddenField.
Use JQuery document.ready
function to set the value again from HiddenField again. JQuery docuemnt.ready
will be called on each Postback
.
Upvotes: 0
Reputation: 148110
You have have html control to keep their values on postback by making them runat="server" e.g.
<input type="text" id="txt1" runat="server" />
Upvotes: 1