Display animated gif in asp net page while executing web service

ASP.NET is a powerful programming language that allows developers to dynamic web applications. One common requirement in web development is to display an animated GIF on an ASP.NET page while executing a web . In this article, we will explore different to achieve this functionality.

Approach 1: Using JavaScript

One way to display an animated GIF while executing a web service is by using JavaScript. We can use the setTimeout function to delay the execution of the web service call and display the GIF in the meantime.






In this example, we have an image element with the ID “loadingImage” that initially has its display set to “none”. When the “Call Web Service” button is clicked, the displayLoading function is . This function sets the display property of the image element to “block” to make it visible and then uses the setTimeout function to delay the execution of the callWebService function by 1 second.

Approach 2: Using UpdatePanel

Another approach to display an animated GIF while executing a web service is by using the UpdatePanel control in ASP.NET. The UpdatePanel allows us to update specific parts of a web page asynchronously without the page.




    
        
        
    
    
        
    

In this example, we have an UpdatePanel control that contains an Image control with the ID “loadingImage” and a Button control with the ID “btnCallWebService”. The Image control is initially set to be invisible by setting its Visible property to false. When the “Call Web Service” button is clicked, the btnCallWebService_Click event handler is executed, and the UpdatePanel updates its content asynchronously without refreshing the entire page.

These are just two approaches to display an animated GIF in an ASP.NET page while executing a web service. Depending on your specific and the complexity of your application, you may choose one approach over the other. Remember to adapt the code examples to fit your project structure and conventions.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents