|
-
Jan 24th, 2011, 01:22 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] asp.NET MVC1 - Call controller action on timer tick
Hi all,
I'm currently working on an ASP.NET MVC1 web application and we have a page, a timesheet, that the user use to enter his the time he passed working on his tasks. The problem we are having right now is that the session's timeout is 20min and we don't want to change it. With the timesheet page though, a lot of users simply open it, start entering some time entries, go do someting else and then come back etc... during that their session timed out and as they didn't saved, they lost their entries.
I would like to implement an auto-save feature, like saving the timesheet no matter what, every 2 minutes.
Edit : Like the auto-save that you get when you are editing a document on google docs.
So I'm trying to find the best approach. We already have a controller action that validates and save the timesheet data when the user clicks the save button (using Html.ActionLink) so I would like to call the same action but from a timer_tick event handler if possible. Right now the only way I can think of is using Ajax to call the proper controller action, but I just don't like it, I find it hard to read and maintain for the next guy who will have to work on that. I would have like to simply had a timer and call the controller's action from the behind code I haven't been able to figure out how yet.
Edit : The action that is currently called does some validations and returns a view. Also, the parameters that needs to be sent to the Action are the current Dataview and an "action" which comes from an enum, so I'm not sure that it is accessible from JQuery. In other words, If I don't find a work around solution I guess I'll have good refactoring to do.
So I'm basically taking any suggestion on how to implement the auto-save.
Thanks
Last edited by stlaural; Jan 31st, 2011 at 10:19 AM.
Reason: added details.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jan 24th, 2011, 02:03 PM
#2
Re: asp.NET MVC1 - Call controller action on timer tick
Hello,
You have posted your question in the ASP.Net forum, but we actually have an ASP.Net MVC forum as well.
I am going to move your thread there, as this is where you question belongs.
Thanks
Gary
-
Jan 24th, 2011, 02:08 PM
#3
Thread Starter
Fanatic Member
Re: asp.NET MVC1 - Call controller action on timer tick
Thanks Gary, can't believe I missed it, it's just 2 positions bellow the ASP.Net section. :S
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jan 24th, 2011, 02:10 PM
#4
Re: asp.NET MVC1 - Call controller action on timer tick
Ha ha 
It hasn't been around too long, so not common knowledge yet.
Gary
-
Feb 2nd, 2011, 12:59 PM
#5
Thread Starter
Fanatic Member
Re: asp.NET MVC1 - Call controller action on timer tick
Well I finally found a solution. I used the jQuery Form Plugin, available here. It basically allows you to submit an existing html form, which I really needed as I am using Asp.Net MVC1 and the action I am calling rebuilds the viewdata from a table that is in the form. And I simply setted an interval that suits my need in order to call that action regularly.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Feb 3rd, 2011, 02:26 AM
#6
Re: [RESOLVED] asp.NET MVC1 - Call controller action on timer tick
Hello,
Are you tied to MVC 1? I was at a presentation the other weekend about MVC 3.0, and it seems like things have moved on quite a bit. Might be worth looking to move up.
Gary
-
Feb 3rd, 2011, 05:38 AM
#7
Thread Starter
Fanatic Member
Re: [RESOLVED] asp.NET MVC1 - Call controller action on timer tick
Yeah, for this application I'm currently tied to MVC1 as we are only doing small improvements and bug fixes on it. We are supposed to start developing the next version soon though, this one will use MVC2 or even 3 if we're lucky and if its available at that moment.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Feb 3rd, 2011, 06:49 AM
#8
Re: [RESOLVED] asp.NET MVC1 - Call controller action on timer tick
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|