Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6669619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:10:19+00:00 2026-05-26T03:10:19+00:00

In my project I need to show a Progress bar in the Page load

  • 0

In my project I need to show a Progress bar in the Page load event.
Basically I get a requiest from another application. Based on the request
My page will create a pdf file. As it will take time to create the pdf file
I need to display a progress bar or an animated gif image as the page is being created.
Any idea how to do it. Remember I am not using any button_click events here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:10:20+00:00Added an answer on May 26, 2026 at 3:10 am

    I imagine something like this could work:

    On document.ready have the gif image displayed by calling a function like this:

    function ShowProgressBar(booleanValue)
    {    if(booleanValue)
           $('#elementcontaingimage').show('slow');
         else 
           $('#elementcontaingimage').hide('slow');
    }
    

    with true parameter: ShowProgressBar(true);

    And after the PDF is done being generated; just call something like:

    ClientScriptManager cs = Page.ClientScript;
    cs.RegisterClientScriptBlock(this.GetType(), "key", "ShowProgressBar(false);", false);
    

    But I have the feeling that it won’t be as simple :S

    UPDATE – working example

    I figured out a way to make it work but you will need to separate the code that generates the PDF into a different page whose only purpose will be to write the PDF file to the response stream. Better yet, you could write an HttpHandler to write the PDF file to the Response Stream but for the purposes of this example, I’ll write the PDF file from a regular aspx page.

    Step 1: Insert the following markup and javascript code in your page.

     <div id="imageDiv">
            <img alt="" src="images/ajax-loader.gif" />
        </div>
        <script language="javascript" type="text/javascript">
            function ShowProgressBar(booleanValue) {
                if (booleanValue) {
                    $('#imageDiv').show('slow');
                    createIframe();
                }
                else 
                    $('#imageDiv').hide('slow');
    
            }
            function callback(parent) {
                ShowProgressBar(false);
            }
            function createIframe() {
                $('<iframe />', {
                    name: 'myFrame',
                    id: 'myFrame',
                    src: 'PageGeneratingPDF.aspx',
                    style: 'display:none;'
                }).appendTo('body').load(function () {
                    callback(this);
                });
            }
            window.onload = ShowProgressBar(true);
        </script>
    

    Explanation: On page load ShowProgressBar is called to start displaying an animated gif image. The following line -createIframe();- creates an iframe dynamically and sets the src attribute to be the url of the page that will write the PDF to the Response Stream. It then appends the iframe to the page body and attaches a callback function that will be invoked when the iframe is done loading. Since the callback function is called when PageGeneratingPDF.aspx is finished generating the PDF file, the only thing left for the callback function to do is hide the div containing the animated gif image.

    The PageGeneratingPDF.aspx code behind could look something like this:

    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.Sleep(10000);//Give the sensation that the pdf file takes long to generate
        //replace line below with actual code that generates the PDF file
        byte[] pdf = File.ReadAllBytes(Server.MapPath(@"~/file.pdf"));
        Response.AddHeader("Content-disposition", "attachment; filename=report.pdf");
        Response.ContentType = "application/octet-stream";
        Response.BinaryWrite(pdf);
        Response.Flush();
        Response.End();        
    }
    

    You are done. The output will be something like this.

    Initially…

    first page

    After generating the PDF…

    second image

    This other question in StackOverflow, was very helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Junits I have in my project need to load property files from the
In my android project I need to show the notification when the certain event
I need to implement progress bar in an android project when an intent is
i need to show stories details and tags' names in my php/mysql project .
Can I use osmdroid in a Titanium Mobile project? I need to show an
For my project report, i need to show the class diagram of the software
I can't figure out how to organize classes in project... I need to show
Hai, I have create a iPhone project where I need to show the current
I need help to create a Web Setup project for an MVC2 application I
I'm working on a project where I need to open a winform from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.