Solved

Problems with showing label text

Posted on 2006-06-27
11
310 Views
Last Modified: 2010-08-05
Hi experts,

I nonmodal pop up a window that loads an .aspx page that displays some data about a file.  The user clicks a button to download the file.  I want to be able to display a message in a label when they click the button like "Downloading...."  then when the download is done it would say "Download complete" or simply erase the downloading message.  I need this because sometimes it cranks away a bit after clicking the button and to the user it looks like it's doing nothing.

I was able to successfully do the first part by adding an onclick attribute to the server button, but for the life of me I can't figure out how to make it go away.  It seems to ignore all message.Text = "" commands.  Here is my code:

RELEVANT CODE FROM THE ASPX:
=======================
<head>
<script language="javascript">
     function showMessage() {
         document.getElementById("message").innerHTML = "Downloading file......";
     }            
</script>
</head>
.
.
.
<tr>
     <td colspan="2"><asp:Label ID="message" runat="server" /></td>
</tr>
<tr>
     <td colspan="2"><input ID="downloadReport" type="submit" value="Download" runat="server"></td>
</tr>

CODEBEHIND CODE:
=============
private void Page_Load(object sender, System.EventArgs e)
{
     downloadReport.Attributes.Add("onClick","return showMessage();");
}

private void downloadReport_ServerClick(object sender, System.EventArgs e)
{
     downloadFile(fileID,fileName.Text,contentType.Text,fileSize.Text);
}
private void downloadFile(int binID,string fileName, string contentType, string fileSize)  
{
    .
    .
    .
    conn.Open();
    cmd = new OracleCommand("SELECT blob from sometable where bin_id= :bin_id",conn);
    OracleParameter bin_id = cmd.Parameters.Add("bin_id",OracleDbType.Int64);
    bin_id.Value = binID;
    dr = cmd.ExecuteReader();
    Response.ContentType = contentType;
    Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", fileName));
    Response.AddHeader("Content-Length", fileSize);
    oFileUp.TransferBlob(dr,0);    
    Response.Close();
}


The oFileUp object above is the SoftArtisans FileUp, but I don't think that matters.  Anyway, when I click the button, the onClick attribute added in the Page Load correctly displays "Downloading file...."  in the label.  But I can't make this disappear.  I have tried:

-- Adding message.Text = "" after the TransferBlob method in the downloadFile function
-- Adding message.Text = "" after the call to downloadFile

I am at a loss.  Thanks for your help.
0
Comment
Question by:dentyne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16992285
 function showMessage() {
         document.getElementById("message").innerText = "Downloading file......";
     }  
0
 
LVL 1

Author Comment

by:dentyne
ID: 16992301
The showMessage() function works fine.  It displays the "Downloading file....." message when the server button is clicked.   My problem is making it disappear once the download is complete.
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16992352
message.Text = " "  will work
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16992387
private void downloadReport_ServerClick(object sender, System.EventArgs e)
{
     downloadFile(fileID,fileName.Text,contentType.Text,fileSize.Text);
      message.Text = "";
}
0
 
LVL 1

Author Comment

by:dentyne
ID: 16992442
Where do I put this message.Text = " "?  As stated in the problem, I tried blanking or changing the text by putting that line in the downloadFile function before the "Response.Close();" line.  I have also tried putting it in the downloadReport_ServerClick function after the call to downloadFile.  It does not work.  The file downloads and I still see "Downloading file......" on the screen.

Just to be clearer:

In the ServerClick method:
downloadFile(fileID,fileName.Text,contentType.Text,fileSize.Text);
message.Text = " ";


In the download file method:
message.Text = " ";
oFileUp.TransferBlob(dr,0);
message.Text = " ";
Response.Close();


The message still says "Downloading file...." when the Internet Explorer file download box appears.  Even after I download the file the message is still there.  

0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16992501
try to use
message.Text = " ";
 Response.Flush();
Response.Close();
0
 
LVL 1

Author Comment

by:dentyne
ID: 16992553
Unfortunately that didn't work either.  I tried putting it in all of the places.  Maybe it does have something to do with the FileUp control.  It just seems odd though.  Is there is a way to call a client javascript function after the TransferBlob method that would change it back?
0
 
LVL 7

Assisted Solution

by:pradeepsudharsan
pradeepsudharsan earned 250 total points
ID: 16992674
<script language="javascript">
      function Clear()
            {
              document.getElementById("message").innerText="";
             
            }
      
            </script>

server side

oFileUp.TransferBlob(dr,0);
    String strScript ;
        strScript = "<script>";
        strScript += "Clear();";
        strScript += "</script>";
        Page.RegisterStartupScript("ClientScript", strScript);

        Response.Close();
       
0
 
LVL 1

Author Comment

by:dentyne
ID: 16992829
This is pretty tough.  That script code you gave doesn't work.  But if I comment all all of the response header settings and the transferblob (as if I wasn't downloading), then it does work.  I think that when Internet Explorer gives that File Download box, that something damaging happens and I lose control.   It's pretty frustrating.
0
 
LVL 5

Accepted Solution

by:
vinodhsomasekharan earned 250 total points
ID: 16999223
Hai,

 I think we can't trace the status of the  download dialog shown by the Internet Explorer....

regards
Vinodh
0
 
LVL 1

Author Comment

by:dentyne
ID: 17017247
Thanks for all of the help.  I guess Vinodh is correct in that we can't trace the status of the download dialog.  That is unfortunate.  Pradeep your effort was outstanding and I learned a lot.  I hope you both think the point split is fair.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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