Search code examples
jqueryhtmlasp.netretain

Persist HTML control values after submission in ASPX


I have HTML elements (input, select specifically) in a div tag of an aspx from. I do some calculations on them using Jquery. My submit button performs validation using an onclientclick and if that returns true, then server side actions take place (onclick event of submit button). However, as soon as I submit, the HTML elements loose their value and become blank. I want to retain those values after the submission so that the users can see what they had typed before they submitted. Some people ma suggest <asp:UpdatePanel>. But, I don't want to use .NET AJAX. Can this be done with Jquery/Javascript?

Following is the sample of HTML inside the aspx page.

<input id="txtLength10"  onchange="cc(10);" type="text" class="numeric"  maxlength="25"    />

<select id="ddClass10"><option value="10">Select Class</option></select>

Solution

  • I had no luck on the above question. Finally, I took all the values of the controls that I needed in aspx hiddenfield and then used a checked if there was a value present on that hiddenfield on a onload event.

    $(document).ready(function() {
    if ($('#<%=hdfFILLER.ClientID %>').val() != "") { //use regex to break this string and fill all the html controls }});