Search code examples
c#asp.nethtmlpostbackviewstate

Retain html client control values on postback


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?


Solution

  • 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" />