views:

371

answers:

2

Hi I have written code for sending email in that i have included Save as Draft like in gmail feature. But now i tried simply saving when the Save as Draft button clicked. But i need Once "Save as Draft" button clicked still user need to change the body of email content means it will automatically save the remaining boby of the content using Asp.Net MVC and Jquery.

+1  A: 

You can call the setInterval Javascript function to automatically run code every 30 seconds, like this:

setInterval(function() {
    //Do autosave
}, 30000);  //30,000 milliseconds
SLaks
+1  A: 

To implement the google approach you will need to use ajax to post the draft email content back to the server. Using an interval as suggested by SLaks to initiate your ajax call is a good approach. You will then need a MVC controller that processes / stores the data. Every new email will need an ID of some sort. In psuedo code:

  1. interval gets triggered.
  2. use ajax to post the form data (including the id).
  3. mvc action processes the post by updating the data in the datastore.
  4. when the email is finally sent, clear it from the datastore.

This will allow you to display drafts to the user from where ever they login. If you only want the user to see their drafts, then you will need to tie the datastore to your membership database.

rcravens