Automatic Save Throughout ASP.NET Application? [duplicate] - asp.net

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
ASP.NET Forms autosave
I'm looking for general guidance on how to implement an "auto-save" feature in ASP.NET 4.0. I have an application with a tabbed interface (AJAX Control Toolkit) and a user can make changes in a variety of fields and tabs at any given time. I need to create an auto-save for (1) every time changes are made to fields and (2) save everything every 3 seconds (or what not).
I've never implemented something like this and I'm looking for guidance one it. Obviously, I'm assuming that there's some AJAX involved, I just don't know how to go about it.

Use a web service with ASP.NET AJAX:
http://msdn.microsoft.com/en-us/magazine/cc163499.aspx
http://www.asp.net/ajax/documentation/live/tutorials/ConsumingWebServicesWithAJAXTutorial.aspx
http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
You ship off the data to the server using a web service. You can attach to the change event of the input control (or lostfocus event too), and when it fires, call the web service. For the every X seconds, use window.setTimeout or window.setInterval, and make the call to send all the pages data to the server.
I don't know if it will perform well by sending data that frequently; are you sure you need to do both?

An easy way would be to
Wrap autocomplete form in update panel
Attache .change() listeners to all textboxes ect
Add a javascript timer to the page
In the change event and timer click hidden button to post form back.
Maybe have some cute page has been saved text you update during the postback
Bam all done

Related

In asp.net, how to FULLY ajaxfy a page with a photo gallery retrieved from database by ListView server control?

I believe this is a fundamental question regarding asp.net's way of manipulating database items. Basically the server side way of manipulating database items (using ListView or similar) is outdated due to the post back model is outdated compared to AJAX. Let's say you have forward and backward buttons on the gallery to update images from the database. You need to postback in order to update page. Clearly this could use an ajaxfied approach. I have been thinking about this long and hard and have observed most websites that uses ListView or GridView or whatever do not ajaxfy the process, probably due to the difficulty of this problem. For those that ajaxfy the page, they use the UpdatePanel, which is only "pseudo-ajax".
I would like to know do other programmers have a FULLY ajaxfied way of updating a page of a photo gallery, retrieved from database by ListView? As I said I have been thinking about this long and hard and I think there might be two approaches: First, use ListView to first populate photo gallery. On pressing forward or backword button, use jQuery's ajax method to connect to an .ashx page and use .ashx page to retrieve data items and then use jQuery to update the photo gallery at the client side.
The second way I forsee would be abandoning the ListView altogether and use a for loop in .ashx to populate gallery from the beginning. This approach unifies the initial data retrieval method and the "postback" data retrieval method, which could mean less code needed, since you do not need the aspx page at all.
My question is, what is the realistic way to fully ajaxfy the page mentioned above?
I still use code behind in my asp.net website.. but I do use ajax elements on the .aspx page
take a look at ASP.Net Ajax Control Toolkit
All the Ajax elements, with the benefit or still using code behind
So far the best way I have found would be to use jQuery AJAX to update whatever changes, although it can be much more time consuming than posting back to server and update from there

updating data in a grid or something like that when someone inputs new data !(WITHOUT ANY POSTBACKS)

imagine that i have a web page in my application for inputing data and there is a grid at the bottom of them (showing inputing data)...
i want to force this web page acts like a windows application (mean i do not want any postback after enter and that grid should be updated after inputing data without postback)...
imagine that i opened this page in my pc and my friend has opened this page too / i want when i input data in ajax mode , that grid updated for my friend without any postback / like windows application ...
is timer a good idea for doing this ?
or is there a better way for doing that?
thanks in advance
best regards
You're definitely going to have to go AJAX for this - the simplest (but definitely not the most efficient) method would be to add the AJAX Control Toolkit to your project, wrap your GridView in an UpdatePanel, and have a timer on the page to check the database to see if there's anything newer than last time you checked. If there has been a change, you can either re-databind the grid or just render that new content manually (and update the UpdatePanel).

ASP.NET MVC 2 Getting form values without postback

I have an odd question that im not sure has been asked/answered, and im not sure if mvc can do this but:
I have a really massive page/controller which i have been able to code well enough. The user can edit information on this page and wont get it saved to the database unless they specifically say, save. However, there is a list at the bottom of this page that you can add/edit and delete elements. Adding and editing takes you to a different page, and before the page change happens, i want to save the form data to session memory, but i dont know how to access it outside a postback. Can MVC do this?
I do not believe this is possible. There is no way to interact with Session object outside of some form of postback.
You may want to architect your solution as such that you can mitigate the need to go to a different page and return.
The adding/editing portion of your form could instead be handled through asynchronous web POSTS independent of your main form. JQuery UI's dialog window and UI Tabs come in nicely for sophisticated forms that need CRUD capabilities to other components of your web application.

Json, Timer, Ajax, What is faster (for shared Chronometer)?

I'm developing an application using ASP.Net.
For first the idea: "My WebApp needs an chronometerto be shared by users and all users will se the same value in cronometer. When a user clicks on a button, the cronometer needs to be restarted and all users will need to see that!"
All right, now I'd like to know what's the best choose to improve more performace an make sure that all users will see the same value in chronometer?
Need I use JSon (with jquery in client side), Timer with UpdatePanel of Ajax Extensions, pure Ajax (with JQuery) or any idea to suggested ? Any suggestion for how to shared a cronometer for all users in C# (put information in Cache or database) ?
Thanks all
Cheers
It is impossible for all users to see the same value in the chronometer. JQuery will be faster than an UpdatePanel (an UpdatePanel needs to post the whole page back to the server), but still some kind of polling to the server is needed. You could set the polling period to 1 second - in that case the difference in users' chronometers will be at the most 1 second. Even that value however is too low for a repeating Ajax request and could easily hog browser's resources.

Continuously update an ASP.NET page using AJAX

I have an ASP.NET page that is interacting with a business class. I want to continuously update controls on my page based on user entered values, e.g. update totals. The calculations are embedded in business logic but they're simple enough to reproduce elsewhere. I've thought of three ways to accomplish this:
Dynamically update the page using JavaScript. I don't want to do this because I don't want to risk floating point math problems where the values on the page don't match the values calculated by the business class (those properties are decimals).
Clear calculated fields on changes and force the user to click a re-calculate button. This is a poor user experience and wiring up JavaScript to ASP.NET controls is tedious.
Use an AJAX UpdatePanel, set data entry controls to autopostback, and handle the "changed" event for the control, e.g. TextChanged for TextBox.
The third method seems cleanest to me, provides a nice user experience, and allows me to interact directly with my business class that I've stored in session state.
My question is: Is this a good idea and/or a common practice? Are there better ways to accomplish this?
I haven't done ASP.NET work for a few years and I have a prejudice against autopostback[1]. I've looked at the size of the request and it's currently negligible at 1.5kB. The site will be low use but we may have a small number of users with dial-up connections.
And ASP.NET in general but times are tough.
Personally, I think UpdatePanel is too heavy. You could use jQuery along with an ASP.NET Web service function that outputs JSON.
You're correct in thinking the third option is your best. This is the kind of thing that AJAX is made for. Go for it.

Resources