locked
Save Some Form Data And Continue Later RRS feed

  • Question

  • User-1236024542 posted

    In my web app there is one long form to fill-up and submit.

    I want to create functionality like fill some part today then suddenly something happens or they can't filled whole information at one time so they can to fill-up in parts.

    First they fill-up some data save it and then continue the fill-up remaining field/data later, means when user logged in he/she can see the data they filled and they can continue whenever they want.

    Any suggestion what kind of strategy should I used? Also it would be appreciate if provide some sample code for it.

    Friday, September 8, 2017 4:21 PM

All replies

  • User-335504541 posted

    Hi ritul29,

    I think you could try to use ajax.

    You could call ajax function after user input or modify the value in control.

    In the function you could save the value to a temp table or something else.

    And you could use username as Id of the data.

    For example:

    <script>
        function SaveName(value) {
            var User = document.getElementById('Hidden1');
            $.ajax({
                type: "POST",
                url: "/Home/SaveName",
                data: JSON.stringify({
                    "User": User.value,
                    "Name": value
                }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    alert("success");
                },
                error: function (data) {
                    alert(data.responseText);
                }
            });
        
        }
    </script>
    
    <input id="Hidden1" type="hidden" value="username"/>
    <input id="Text1" type="text" name="name" onchange="SaveName(this.value)"/>

    In the server side:

            [WebMethod]
            public void SaveName(string User, string Name)
            {
                //Find the data by User, if not exist create one 
                //Update the Name field
                //Save the change 
    
            }

    And use the temp data to load the page, if the data exist.

    You could refer to the link below for more information:

    http://api.jquery.com/jquery.ajax/

    Best Regards,

    Billy

    Monday, September 11, 2017 7:06 AM