|
Rank: Advanced Member Groups: Member
Joined: 4/4/2008 Posts: 46
|
Hi,
I have a button click event that causes a dataset to be loaded from a SQL Server. The time waiting for the SQL query to complete can be substantial and I would like to use the progress bar to indicate that the action is in process rather than have the user wait for 30 seconds or more staring a static web page.
Since I make a call to the SQL Server and wait for a dataset to be returned, there is no way for me to update the bar directly while waiting. Do you have any sample C# that can be used in a codebehind page to accomplish this???
Here is my code:
protected void btnReport_Click(object sender, EventArgs e) { //Start Endless Progress Bar Here loadRptDs(); // This Call to the SQL Server takes a long time //Stop Endless Progress Bar Here
Response.Write("<script language='javascript'> {window.open(\"Report.aspx\", \"_blank\", \"menubar=0,toolbar=0,location=0,directories=0,scrollbars=1,resizable=1,status=0\");}</script>");
}
Thanks,
Dave
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi Dave, You probably don't really need a progress bar if that's the case --- the progress bar always require you to drive it, so it's useless if you can't update the prorgress information during your call. It would be much easier if you would just use some DHTML to turn on an animated gif image before you triggering an AJAX call to call loadRptDs() on the server side (without AJAX you would be looking for a full page reload, which often causes the animated gif stop playing because the browser thinks if you are updating the page anyway, why should it bother to play the animiated gif for you...). You can try it this way: 1. Place a CallbackPanel in the form (you will want to go over the documentation for CallbackPanel if you are not already familiar with this control); 2. Set btnReport as a trigger for the CallbackPanel; 3. Place an animiated gif in your page. This .gif file is not initially visible (notice its style is set to "display:none"):
Code: HTML/ASPX
<img src="some_image.gif" style="display:none" id="progress_img" />
4. Handle the CallbackPanel's ClientSideBeforeExecute event:
Code: HTML/ASPX
<eo:CallbackPanel ClientSideBeforeExecute="show_progress_img" ....>
.....
</eo:CallbackPanel>
Code: JavaScript
function show_progress_img(callback)
{
var img = document.getElementById("progress_img");
img.style.display = "inline";
}
This way when you click the button, it calls show_progress_img first to display the image, then triggers your server side btnReport_Click event. Hope this help. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 4/4/2008 Posts: 46
|
Very Cool Stuff!!!!
Works great....
Thanks,
Dave
|
|
Rank: Advanced Member Groups: Member
Joined: 4/4/2008 Posts: 46
|
The CallBack Panel appears to affect other ASP controls such as DropDownLists and CheckBoxes.
None of the DropDownLists and one CheckBox in my form have mysteriously stopped working. The DropDownLists simply don't drop down. and one Checkbox cannot be checked.
If I remove the CallBack Panel all is ok.
Is the order of the Callback control in the .aspx page important???? Should it be in a <DIV> by itself????
Please help!!!!
Thanks,
Dave
|
|
Rank: Advanced Member Groups: Member
Joined: 4/4/2008 Posts: 46
|
Ok... I've got the DropDownLists working, but the SelectedItem property always stays is always at 0 after the the CallBackPanel is triggered???? Also the CheckBox.Checked property is always "False".....
Ideas?????
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi Dave,
We are not aware of any such problem. Can you create a test page that demonstrates this problem? Make sure the page can run independently. We will take a look as soon as we have that.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 4/4/2008 Posts: 46
|
Sorry my problem :-) Working fine now...
|
|