?
Solved

ASP.NET,Javascript: Message while retreiving data from database

Posted on 2008-11-12
9
Medium Priority
?
486 Views
Last Modified: 2013-12-17
Hi,
I have a gridview in which I mantain sorting and paging. The problem is that some times it takes time (more that 15 seconds) to show a new page or the resut of a sort. I would like to know how I can show a message to the user, telling that the the system is looking for data. Please don't give me ajax solution as I am not using it in my application.
0
Comment
Question by:karakav
  • 4
  • 3
  • 2
9 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22941284
you can use the ajax progress bar or a splash screen to indicate to the user that some action is being taken
ASP.NET/ AJAX Page Loader Progress Bar/ Splash Screen - http://www.codeproject.com/KB/aspnet/ASPNETAJAXPageLoader.aspx
0
 
LVL 4

Author Comment

by:karakav
ID: 22941458
I think you didn't read well my thread. I say that Ajax is NOT an option for me.
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22941579
sorry my fault
http://www.daniweb.com/forums/thread30366.html is a javascript based sampel but you will have to improvise on that as the demo is called for a specific period time but in your case you might want to hide the progress bar after you results have been bound on the grid on the postback
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 3

Accepted Solution

by:
snowalps earned 2000 total points
ID: 22941786
karakav, you hit the bulls eye. this is by far one of the most common tasks developers like me and you would need. there can be many ways to do it. let me suggest you 2 simple methods to achieve what you must. you can chose what suits you best.

1) dedicate a new htm page for the busy/waiting message you are trying to show. create a new htm page and put on the message on it say " Executing your request..." or someting like that. You can also put up a busy icon image (gif) and put it up along with it. When the ongoing activity is completed, then if you can, put up a session flag and turn it to true  in the main aspx page where the activity was happening. now check for this session flag in the htm page we just created. if the flag is true, redirect to the aspx main page, else remain on the htm page. if you can't set up a session ( i.e  you cant control the exact time when the activity is completed), then let the htm page automatically redirect to the main page after a fixed amount of time.
you can accomplish this with the Meta refresh tag in htm like:

<META HTTP-EQUIV=Refresh CONTENT="2; URL="your main page.aspx">
where the '2' is the time in seconds after which the redirection takes place.

2) second option can be to put up a label on your main aspx page with the "busy" message and toggle it to be hidden if visible , or visible if hidden using a javascript. and call this toggle function on the control that initiates the activity which is taking time to execute( like the sort you mention for which i believe it would be selected index changed for the dropdown that is selected, or the click of a button) you can call the javascript toggle function on the control say for e.g if the activity happens on the click of a button then call is as:

btn.Attributes.Add("onclick", "return toggle();");

where toggle is your function name.
the entire process should be as follows:

a) make the "busy message" label's visible property to true.
b) call the toggle function on page load from html of the aspx page so that the label is hidden after the toggle is executed on page load.
use <body onload="toggleVisibility();"> in html of the main aspx page.
c) now  on page_load event of the aspx page (server side code), call the javascript function on the appropriate control as
btn.Attributes.Add("onclick", "return toggle();");

thats it. this should work for you. give it a shot and let me know when you have any doubt implementing it. if you need the javascript for the toggle function itself, let me know i can send it to you.
cheers!
0
 
LVL 4

Author Comment

by:karakav
ID: 22942601
Actually I would be thankful if you send me a snippet. I failed to implement you solution I don't know why.
0
 
LVL 3

Expert Comment

by:snowalps
ID: 22942669
well you should tell me where you are facing the problem. its easier to sort that way.
the snippet will be only for the toggle function, the rest you need to implement the way i have listed.
i have writtern the code as well in between the lines. its not much of coding actually...
0
 
LVL 4

Author Comment

by:karakav
ID: 22942830
Actually because I am accessing a single method from many locations(sorting,pageindex,page load) I put the following code before and after calling the database:
//Code behind
private void GetData()
{
....
            ClientScript.RegisterStartupScript(typeof(String), "busy", "toggleLabel('none') ;", true);
 
//The data retreival logic goes here
 
            ClientScript.RegisterStartupScript(typeof(String), "freenow", "toggleLabel('') ;", true);
 
}
 
//Here is the Javascript function
 
        function toggleLabel(condi) 
            {
                document.getElementById("lblProgress").style.display = condi;                    
            }            

Open in new window

0
 
LVL 3

Expert Comment

by:snowalps
ID: 22942966
not sure what for you are using the ClientScript.RegisterStartupScript part.

use the below toggle function in your main page for activity.


<script type="text/javascript">      
         
         function toggleVisibility()  
          {          
              var control = document.getElementById("busy");    
              if(control.style.visibility == "visible" || control.style.visibility == "")      
                {
                    control.style.visibility = "hidden";          
                }
                else                
                {
                    control.style.visibility = "visible";      
                }
           }
      </script>
and follow all the steps i mentioned in option 2 and call this function.
0
 
LVL 4

Author Closing Comment

by:karakav
ID: 31515997
Thank you Champion. You really are the best.  Thank you very much.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question