Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to freeze the web page when displaying progress bar?

How to freeze the web page when displaying progress bar?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorialquestion
12 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ipsoftware
    wrote on last edited by
    #1

    Say I have many control buttons in the ASP.NET developped web page, each upon being clicked will do some operatoin which may take some time, when the button is clicked, a progress bar(in my case, I used an animated gif) will be shown while keeping the web page being freezed (by word "freeze", I mean the web page will be made inactive when the progress bar is being displayed in the center of the window, the user can still see the web page, however, he cannot click on any controls in the web page, the web page will be active again until the operation completes and the progress bar disappear.) Can anybody suggest how I may do the web page freezing? thanks a lot!!!

    J M 2 Replies Last reply
    0
    • I ipsoftware

      Say I have many control buttons in the ASP.NET developped web page, each upon being clicked will do some operatoin which may take some time, when the button is clicked, a progress bar(in my case, I used an animated gif) will be shown while keeping the web page being freezed (by word "freeze", I mean the web page will be made inactive when the progress bar is being displayed in the center of the window, the user can still see the web page, however, he cannot click on any controls in the web page, the web page will be active again until the operation completes and the progress bar disappear.) Can anybody suggest how I may do the web page freezing? thanks a lot!!!

      J Offline
      J Offline
      Jesse Squire
      wrote on last edited by
      #2

      Take a peek at the disabled[^] attribute of an HTML element. You could manipulate the disabled attribute from either the client or server side. For your particular situation, I'd recommend using javascript to "freeze" your controls just prior to the form being submitted. While the server processes the POST, the previous screen would be displayed with the controls disabled. Hope that helps. :) --Jesse

      I 1 Reply Last reply
      0
      • I ipsoftware

        Say I have many control buttons in the ASP.NET developped web page, each upon being clicked will do some operatoin which may take some time, when the button is clicked, a progress bar(in my case, I used an animated gif) will be shown while keeping the web page being freezed (by word "freeze", I mean the web page will be made inactive when the progress bar is being displayed in the center of the window, the user can still see the web page, however, he cannot click on any controls in the web page, the web page will be active again until the operation completes and the progress bar disappear.) Can anybody suggest how I may do the web page freezing? thanks a lot!!!

        M Offline
        M Offline
        morphix
        wrote on last edited by
        #3

        I second that, a script could look like this: Javascript: function disableAllInputs() { var inps = document.getElementsByTagName('INPUT'); for(var i=0;i

        I 2 Replies Last reply
        0
        • J Jesse Squire

          Take a peek at the disabled[^] attribute of an HTML element. You could manipulate the disabled attribute from either the client or server side. For your particular situation, I'd recommend using javascript to "freeze" your controls just prior to the form being submitted. While the server processes the POST, the previous screen would be displayed with the controls disabled. Hope that helps. :) --Jesse

          I Offline
          I Offline
          ipsoftware
          wrote on last edited by
          #4

          so you mean when the button is clicked, the javascript function associated with it will freeze the form control before taking backend actions in the .aspx.cs ? right? but in this case, the button will trigger two event functions, one is the javascript function in the .aspx page, another is the function Button_click(..) in the aspx.cs, how can a button be associated with two events? I don't want to call the backend Button_click(..) from the javascript function, and I also don't want to write the Button_click(..) function in the javascript coz I think writing this function in the .aspx.cs file will be better for maintenance. I like the javascript function to do the freezing only, the backend button_click does the real implementation, once it is done, the form controls will be unfreezed Thank u for your help!!!

          I 1 Reply Last reply
          0
          • M morphix

            I second that, a script could look like this: Javascript: function disableAllInputs() { var inps = document.getElementsByTagName('INPUT'); for(var i=0;i

            I Offline
            I Offline
            ipsoftware
            wrote on last edited by
            #5

            Thank you, actually, my thinking is when the button is clicked, the javascript function associated with it will freeze the form control before taking backend actions in the .aspx.cs. but in this case, the button will trigger two event functions, one is the javascript function in the .aspx page, another is the function Button_click(..) in the aspx.cs, how can a button be associated with two events? I don't want to call the backend Button_click(..) from the javascript function, and I also don't want to write the Button_click(..) function in the javascript coz I think writing this function in the .aspx.cs file will be better for maintenance. I like the javascript function to do the freezing only in the .aspx page, the backend button_click does the real implementation, once it is done, the form controls will be unfreezed. Possbile to do that? Thank u for your help!!!

            1 Reply Last reply
            0
            • I ipsoftware

              so you mean when the button is clicked, the javascript function associated with it will freeze the form control before taking backend actions in the .aspx.cs ? right? but in this case, the button will trigger two event functions, one is the javascript function in the .aspx page, another is the function Button_click(..) in the aspx.cs, how can a button be associated with two events? I don't want to call the backend Button_click(..) from the javascript function, and I also don't want to write the Button_click(..) function in the javascript coz I think writing this function in the .aspx.cs file will be better for maintenance. I like the javascript function to do the freezing only, the backend button_click does the real implementation, once it is done, the form controls will be unfreezed Thank u for your help!!!

              I Offline
              I Offline
              ipsoftware
              wrote on last edited by
              #6

              sorry, just to restate my question, suppose I want to display a progress bar upon clicking on the button. It will trigger a backend function (in the .aspx.cs file) which may take quite some time to complete upon being clicked. The funtion call will be synchronous. Coz the implementation takes some time to complete, I like to display a progress bar (I used a animated GIF ) to indicate the ongoing activity. However, if I write code in the behind like the following Button_Click(...){ image.visible = true; call function; image.visible = false; } This won't work since it is a synchronous call, the .aspx page won't get image rendered until the function implementation completes. So setting image visibility status here has no use. However, how may I achieve my purpose? That is: once the button is clicked, the image is displayed first, then the time-consuming function will start exectuing. once it is done, the image will be set to be not visible. I don't want to write the Button_Click(...) in the .aspx page as I want separation between GUI and backend control. Is it possible to do that? thank u!!!

              J 1 Reply Last reply
              0
              • M morphix

                I second that, a script could look like this: Javascript: function disableAllInputs() { var inps = document.getElementsByTagName('INPUT'); for(var i=0;i

                I Offline
                I Offline
                ipsoftware
                wrote on last edited by
                #7

                sorry, just to restate my question, suppose I want to display a progress bar upon clicking on the button. It will trigger a backend function (in the .aspx.cs file) which may take quite some time to complete upon being clicked. The funtion call will be synchronous. Coz the implementation takes some time to complete, I like to display a progress bar (I used a animated GIF ) to indicate the ongoing activity. However, if I write code in the behind like the following Button_Click(...){ image.visible = true; call function; image.visible = false; } This won't work since it is a synchronous call, the .aspx page won't get image rendered until the function implementation completes. So setting image visibility status here has no use. However, how may I achieve my purpose? That is: once the button is clicked, the image is displayed first, then the time-consuming function will start exectuing. once it is done, the image will be set to be not visible. I don't want to write the Button_Click(...) in the .aspx page as I want separation between GUI and backend control. Is it possible to do that? thank u!!!

                1 Reply Last reply
                0
                • I ipsoftware

                  sorry, just to restate my question, suppose I want to display a progress bar upon clicking on the button. It will trigger a backend function (in the .aspx.cs file) which may take quite some time to complete upon being clicked. The funtion call will be synchronous. Coz the implementation takes some time to complete, I like to display a progress bar (I used a animated GIF ) to indicate the ongoing activity. However, if I write code in the behind like the following Button_Click(...){ image.visible = true; call function; image.visible = false; } This won't work since it is a synchronous call, the .aspx page won't get image rendered until the function implementation completes. So setting image visibility status here has no use. However, how may I achieve my purpose? That is: once the button is clicked, the image is displayed first, then the time-consuming function will start exectuing. once it is done, the image will be set to be not visible. I don't want to write the Button_Click(...) in the .aspx page as I want separation between GUI and backend control. Is it possible to do that? thank u!!!

                  J Offline
                  J Offline
                  Jesse Squire
                  wrote on last edited by
                  #8

                  Things happen a bit differently then you're thinking. Web development can be pretty convoluted, so bear with me. I'll do the best I can to explain things clearly. You may need to re-read a few times and try some proofs-of-concept before it all makes sense. Javascript is a client-side technology. It cannot call a server side function in the manner that you're thinking. It can simply operate on the HTML that has already been sent to the browser. In order to call your server side function, the page must post back to the server. By posting to the server, you are sending the server a request. The server will respond to that request by sending a stream of HTML back to the client, once processing is complete, which will replace the current page that you see. It is exactly the syncronous nature of the request that we're going to exploit. While the browser is waiting for the server to respond to the latest request, the current response(page) is still being displayed. To try and simplify: If you postback for a long operation, the current page will still be displayed. So, in regards to your last question about having two handlers for a button click event... you would be assigning one handler for the client (browser) to execute, and one for the server to execute. The client handler runs first and can only interact with the current page. For example, setting the progress bar graphic to visible and locking the form elements. Once that client handler is run, the browser will then post the request to the server. The server will process the request and call your server-side Click handler, which runs your long operation. While the server is running your operation, the browser will still be displaying the current page, with progress graphic. You won't have to worry hiding the graphic. When the server responds (your long operation is complete), it will do so by sending a stream of HTML. The browser will use the new HTML to replace the current page with a new one. I hope that helps a bit. My advice would be for you would be to experiment with the page processing cycle. Watch it in action, and how control flows from the client to the server and back. All the explainations in the world won't make things as clear as playing with things. Good luck. :) --Jesse Note:To try and keep things simple, I am completly ignoring remote scripting here. Remote scripting allows you to run server operations asynchronously and refresh smaller portions of a page in-line. If you're interested in re

                  I 1 Reply Last reply
                  0
                  • J Jesse Squire

                    Things happen a bit differently then you're thinking. Web development can be pretty convoluted, so bear with me. I'll do the best I can to explain things clearly. You may need to re-read a few times and try some proofs-of-concept before it all makes sense. Javascript is a client-side technology. It cannot call a server side function in the manner that you're thinking. It can simply operate on the HTML that has already been sent to the browser. In order to call your server side function, the page must post back to the server. By posting to the server, you are sending the server a request. The server will respond to that request by sending a stream of HTML back to the client, once processing is complete, which will replace the current page that you see. It is exactly the syncronous nature of the request that we're going to exploit. While the browser is waiting for the server to respond to the latest request, the current response(page) is still being displayed. To try and simplify: If you postback for a long operation, the current page will still be displayed. So, in regards to your last question about having two handlers for a button click event... you would be assigning one handler for the client (browser) to execute, and one for the server to execute. The client handler runs first and can only interact with the current page. For example, setting the progress bar graphic to visible and locking the form elements. Once that client handler is run, the browser will then post the request to the server. The server will process the request and call your server-side Click handler, which runs your long operation. While the server is running your operation, the browser will still be displaying the current page, with progress graphic. You won't have to worry hiding the graphic. When the server responds (your long operation is complete), it will do so by sending a stream of HTML. The browser will use the new HTML to replace the current page with a new one. I hope that helps a bit. My advice would be for you would be to experiment with the page processing cycle. Watch it in action, and how control flows from the client to the server and back. All the explainations in the world won't make things as clear as playing with things. Good luck. :) --Jesse Note:To try and keep things simple, I am completly ignoring remote scripting here. Remote scripting allows you to run server operations asynchronously and refresh smaller portions of a page in-line. If you're interested in re

                    I Offline
                    I Offline
                    ipsoftware
                    wrote on last edited by
                    #9

                    exactly, you are right, I got your idea. Sorry for my stupid question, I just cannot make the image to be visible, I am trying to write the script. In the script function showImage() { document.form.image1.Visible = true; //which is not working, cause for a html image, it has //no "visible" property, is the image is at server control, I cannot set //the visibility property value here. and no Hidden //property is available. } I just cannot manage the image visibility. I did a search in goole, there is no finding. Please forgive me if this question is too stupid! Thank u!

                    J 1 Reply Last reply
                    0
                    • I ipsoftware

                      exactly, you are right, I got your idea. Sorry for my stupid question, I just cannot make the image to be visible, I am trying to write the script. In the script function showImage() { document.form.image1.Visible = true; //which is not working, cause for a html image, it has //no "visible" property, is the image is at server control, I cannot set //the visibility property value here. and no Hidden //property is available. } I just cannot manage the image visibility. I did a search in goole, there is no finding. Please forgive me if this question is too stupid! Thank u!

                      J Offline
                      J Offline
                      Jesse Squire
                      wrote on last edited by
                      #10

                      ipsoftware wrote: Please forgive me if this question is too stupid! Not to worry, there is no such thing. We've all been there before. Web development is a tough thing to wrap your brain around, until you get used to it. :) It looks like your code is the javascript to show the image? Remember that this is happening on the client side, so you're not going to have to think CSS for display properties. What you're going to want to do is something like:

                      function showImage(imageId)
                      {
                        var image = document.getElementById(imageId);
                        
                        if ((image != null) && (typeof(image) != 'undefined'))
                        {
                          image.style.visibility = 'visible';
                        }
                      }
                      

                      Don't forget that when you call the function, you will need to pass in the id of your image as the argument. If you're using an HTML image tag, it will just be the value of the id attribute. If you're using the ASP.NET image control, you will need to use the ClientId property. Hope that helps. :) --Jesse

                      I 1 Reply Last reply
                      0
                      • J Jesse Squire

                        ipsoftware wrote: Please forgive me if this question is too stupid! Not to worry, there is no such thing. We've all been there before. Web development is a tough thing to wrap your brain around, until you get used to it. :) It looks like your code is the javascript to show the image? Remember that this is happening on the client side, so you're not going to have to think CSS for display properties. What you're going to want to do is something like:

                        function showImage(imageId)
                        {
                          var image = document.getElementById(imageId);
                          
                          if ((image != null) && (typeof(image) != 'undefined'))
                          {
                            image.style.visibility = 'visible';
                          }
                        }
                        

                        Don't forget that when you call the function, you will need to pass in the id of your image as the argument. If you're using an HTML image tag, it will just be the value of the id attribute. If you're using the ASP.NET image control, you will need to use the ClientId property. Hope that helps. :) --Jesse

                        I Offline
                        I Offline
                        ipsoftware
                        wrote on last edited by
                        #11

                        Now, upon clicking on the button, the hidden image is shown. However, surprisingly, the animated gif becomes a still one while the backend time-consuming activity is in progress. The image is not animated any more. In the code file behind. I wrote: private void Page_Load(object sender, System.EventArgs e) { Button1.Attributes.Add("onclick","showImage();"); } public Button1_click(....) { time consuming operation here... } then one the .aspx file, I wrote the script as: function showImage() { document.getElementById(imageID).style.visibility = "visible"; } How come the image is not animated any more while the time-consuming function is running behind??

                        J 1 Reply Last reply
                        0
                        • I ipsoftware

                          Now, upon clicking on the button, the hidden image is shown. However, surprisingly, the animated gif becomes a still one while the backend time-consuming activity is in progress. The image is not animated any more. In the code file behind. I wrote: private void Page_Load(object sender, System.EventArgs e) { Button1.Attributes.Add("onclick","showImage();"); } public Button1_click(....) { time consuming operation here... } then one the .aspx file, I wrote the script as: function showImage() { document.getElementById(imageID).style.visibility = "visible"; } How come the image is not animated any more while the time-consuming function is running behind??

                          J Offline
                          J Offline
                          Jesse Squire
                          wrote on last edited by
                          #12

                          Hrmm... odd. To be honest, I don't really know why that would be. Perhaps one of these articles could help?

                          • NicsBar Progress (Loading) Control Bar[^], by Nick Hermans
                          • ASP.NET ProgressBar Control[^], by xicoloko
                          • A simple progress bar web user control[^], by Steven Campbell
                          • FileUploadProgressBar in ASP.NET (C#)[^], by mavus74.net

                          If none of those are helpful, try posting this problem as a new thread. Another member may have a better idea about why your animation is freezing. Hope that helps a bit. :) --Jesse

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups