javascript - How to implement an "Auto Save" or "Save Draft" feature in ASP.NET? -


i have registration form in asp.net 2.0. want save registration form fields either clicking on submit button or should saved every 5 seconds.

for example have 3 fields in registration page:

uid pwd name

the user has entered uid , pwd , whilst entering name previous values should saved without interruption of user inputs

how in asp.net?

you snippet of javascript & jquery. have function that's fired timer periodically reads form data want save , posts savedraft.aspx page. in page persists data somewhere (such database).

if user logs out or session lost can query data , pre-populate form if data exists.

on data entry aspx page:

// usual asp.net page directives go here  <html xmlns="http://www.w3.org/1999/xhtml">   <head runat="server">     <script type="text/javascript" src="scripts/jquery-1.4.1.min.js" ></script>   </head>   <body>     <form id="form1" runat="server">       <div>         <asp:textbox id="username" runat="server" /><br />         <asp:textbox id="password" runat="server" /><br />         <asp:textbox id="realname" runat="server" /><br />         <asp:button id="submit" onclick="submit_click"                usesubmitbehavior="true" runat="server" />       </div>     </form>      <script type="text/javascript">       $(document).ready(function () {         // configure save every 5 seconds         window.setinterval(savedraft, 5000);       });        // magic happens here...       function savedraft() {         $.ajax({           type: "post",           url: "savedraft.aspx",           data: ({             username: $("#<%=username.clientid %>").val(),             password: $("#<%=password.clientid %>").val(),             realname: $("#<%=realname.clientid %>").val()           }),           success: function (response) {             alert('saved draft');           }         });       }     </script>   </body> </html> 

in savedraft.aspx page:

public partial class savedraft : system.web.ui.page {   protected void page_load(object sender, eventargs e)   {     string username = request.form["username"];     string password = request.form["password"];     string realname = request.form["realname"];      // save data somewhere @ point       } } 

that should started.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -