Doing a ajax / json add to database, and have a "wait doing operation" icon
I got a part on my page I want to improve. It's a file upload that users can add their contacts from files like excel, csv & outlook. I read the contacts and place them in the database, so what I would like to do is to have a regular icon that spins while that operation is doing that, how could I do that? Ajax? I don't want progress bar for the file upload but the operation for reading the file
EDIT: I want to know how to make this wo开发者_运维知识库rk with the add to database using ajax. like should I use a updatepanel? how I could combine a ajax callback with the spinning icon
Thanks
You can generate your own spinning icon on www.ajaxload.info. If you combine it with the jQuery BlockUI plugin, you can display your own modal wait screen.
Spin a GIF.
http://www.ajaxload.info/
If you are using the asp:fileupload, there is a couple things that you can do.
Take advantage of the fact that the asp:fileupload takes a bit of time to upload the file and that is also performs a post-back.
1) put a client-side onclick event for the 'upload' button that will display your spinny graphic and give a message saying 'file being parsed and added to database'.
2) put the server-side onclick event for the 'upload' button that will upload the file, parse it and insert records into the database.
3) when the server-side onclick finishes, the remainder of the page lifecycle occurs and the user gets a fresh page returned to them. And when the browser receives the new page, the spinny graphic will no longer be visible.
This won't allow you to change the message during the upload, but it is quick and easy.
The alternative would be to look at jquery and do some ajax calls.
精彩评论