开发者

Well performing method to auto-save and re-populate large ASP.NET form

My question is about a high performance way to implement auto-saving in an ASP.NET 4.0 WebForms app.

I've read a lot on using the various jQuery autosave plugins but they all seem to be best used for minimal input elements. And I haven't found a solution that will populate the ASP.NET form again when the user returns to the form.

I have a FormView with a lot of elements, and a nested listview and formview. Using LinqDataSource to populate the FormView and its children.

Webserver is IIS 7. DB is SQL Server via Linq to SQL and I have access to MSMQ or any other server components required.

I have implemented auto-saving using an UpdatePanel with form elements set to AutoPostBack, and a bit of custom javascript to force async requests to be sequential. This is to avoid concurrency errors in Linq to SQL. Each UpdatePanel async post back saves the entire form to a draft table in SQL Server. It's not very elegant but it does work - slowly!

The problem is that the round trip is too slow. This causes form changes made during saving to not be saved, and also the form to jump back to the saved element, if the user has scrolled in the meantime.

So I'm now thinking I need to:

  1. Keep the same method, populate the linq entity from the form and save it in MSMQ. I would then pull this out and persist it when the user Submits the form (or maybe on Session End, or when they log in again next time); 开发者_开发技巧or
  2. Use something like https://github.com/nervetattoo/jquery-autosave/ and save the serialized form data to MSMQ. This would be pretty fast, but the issue is that I am not sure how to put the data back in the ASP.NET form when the user returns to the form in subsequent sessions.

I've also thought about trying to save just the 'sending' form input value on each post back. I could do this in a dictionary and maintain the dictionary in MSMQ.

BTW, I can't use the Cache or Session because I have to ensure that the form data is kept even if the user closes the browser. So I need something more robust.

Very interested in your opinions - all help greatly appreciated!

Cheers..


In previous work, having a control panel with a hidden button or timer inside it worked just fine. It is normal that the user adds more stuff while/after auto-save. That's why it's an auto-save not final thing. Those changes will be saved in next auto-save.

Using normal one UpdatePanel in the page for entire form (the controls not inside it, inside it only a timer control or button control), did not require me to do anything with sequential JS or so. I think you are doing auto-save "very" often maybe? 30-120 seconds should be fine for large form.

Normally you'll have yeah drafts thing in MSMQ or DB or whatever, if exists when the user comes to work on the form, fill from it, if not, work normally.

The jQuery plug-in seems very interesting too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜