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 7914169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:01:14+00:00 2026-06-03T14:01:14+00:00

I have a function inside my .aspx.cs code which takes wuite a long time

  • 0

I have a function inside my .aspx.cs code which takes wuite a long time to do the processing until when I want to display a cool loading animation.
I looked some of the earlier posts but either these didn’t work for me, or were having solution specific to Page loading scenario (not loading a while a function completes).

I guess the right approach would be to fire a Javascript startLoader() function just before the the main function starts (which takes a long time), and then call a stopLoader() from the .aspx.cs itself to stop the loader when the function ends. Any suggestions how to implement this?

  • 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-06-03T14:01:17+00:00Added an answer on June 3, 2026 at 2:01 pm

    Yes, I’ve done this in ASP.NET Web From (not a ASP.NET MVC solution). You need to provide OnSubmit client side event handler. It basically break down to three parts: Javascript, HTML Div, and one line code behind:

    Javscript:

        function ShowLoading(e) {
            // var divBg = document.createElement('div');
            var divBg = document.getElementById('blockScreen');
            var divLoad = document.createElement('div');
            var img = document.createElement('img');
    
            img.src = 'images/ajax-loader.gif';
            divLoad.setAttribute("class", "blockScreenLoader");
            divLoad.appendChild(img);
    
            divBg.appendChild(divLoad);
    
            document.getElementById('blockScreen').style.display = 'block';
    
            // These 2 lines cancel form submission, so only use if needed.
            //window.event.cancelBubble= true;
            //e.stopPropagation();
        }
    
        function HideLoading() {
            //alert('hideloading');
            document.getElementById("form1").onsubmit = null;
            document.getElementById('blockScreen').style.display = 'none';
            //alert('done');
        }
    

    Add following DIV

     <div id="blockScreen" class="blockScreen" style="display:none">&nbsp;</div>
    

    Finally, add the following to Page_Load in code behind.

     Page.ClientScript.RegisterOnSubmitStatement(this.GetType(), "submit", "ShowLoading()");
    

    Now, all of your page postbacks are essentially have to call onsubmit event. It will display the animation before the page postback finishes.

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

Sidebar

Related Questions

In GridViewData.aspx.cs I have a method I want to call inside a javacsript function.
I have an AJAX function inside a javascript file and I want it to
I have this code snippet inside a function that checks if an object exists
I have the following loop inside an function init(); which is executed onload, I
Inside my template function I have the following code: TypeName myFunction() { TypeName result;
I have a aspx page and inside I have called a .ascx page which
I have taken function functionRemainCount() in .js page. I want to call inside the
I have a function defined inside the script tags of head.(in a JSP) I
I have the following function defined inside my linked list class. The declaration in
I have a bit of a quandary. I need to call a function inside

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.