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

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.
LVL 4
karakavAsked:
Who is Participating?
 
snowalpsCommented:
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
 
Anurag ThakurTechnical ManagerCommented:
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
 
karakavAuthor Commented:
I think you didn't read well my thread. I say that Ajax is NOT an option for me.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Anurag ThakurTechnical ManagerCommented:
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
 
karakavAuthor Commented:
Actually I would be thankful if you send me a snippet. I failed to implement you solution I don't know why.
0
 
snowalpsCommented:
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
 
karakavAuthor Commented:
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
 
snowalpsCommented:
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
 
karakavAuthor Commented:
Thank you Champion. You really are the best.  Thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.