3

I am having page in that when we click on create button its sends web request to get the all links but mean while it takes some time to get all links working or not so at that time I want to put image load

 Button ID="btnRender" runat="server" Text="Page Render" OnClick="btnRender_Click" />
        <asp:Button ID="btn_submit" runat="server" Text="Submit" OnClientClick="javascript:finda();" />
        <asp:Button ID="btn_createlink" runat="server" Text="Create link" OnClick="btn_createlink_Click" />

i want to call on btn_createlink_Click" button when user clicks the image or text should appear

hitarth
  • 317
  • 4
  • 5
  • 19

3 Answers3

7

Without Ajax Tool:
This will call the loading image on button click and hide the image on page load completes.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
      function ShowProgressBar() {
        document.getElementById('dvProgressBar').style.visibility = 'visible';
      }

      function HideProgressBar() {
        document.getElementById('dvProgressBar').style.visibility = "hidden";
      }
    </script>
</head>
<body onload="javascript:HideProgressBar()" >
    <form id="form1" runat="server">
     <div>
  <div style="float:left;">
      <asp:Button ID="btn_createlink" runat="server" Text="Create link" OnClick="btn_createlink_Click" OnClientClick="javascript:ShowProgressBar()" />
  </div>
  <div ID="dvProgressBar" style="float:left;visibility: hidden;" >
        <img src="/images/progress_bar.gif" /> resolving address, please wait...
  </div>
  <br style="clear:both" />
</div>
    </form>
</body>
</html>


Sunil
  • 2,885
  • 5
  • 34
  • 41
0

You can make this happen with the help of Multithreading with the BackgroundWorker Component. Have a look on Multithreading with Backgroundworker

Backgroundworker C# backgroundworker

and this

You can call your loading.gif image in _Dowork method. Hope this helps.

Community
  • 1
  • 1
Sandy
  • 2,429
  • 7
  • 33
  • 63
  • sorry bro its like (http://validator.w3.org/checklink) so when user will click on check its takes some time right to check links at that time i want that loading image – hitarth Apr 09 '13 at 06:16
0

EDIT:

You might want to have a look at HttpResponse.Flush

Forces all currently buffered output to be sent to the client. The Flush method can be called multiple times during request processing.

See the following link: HttpResponse.Flush Method

You could show a loading image and call this method every X number of loaded links.

OLD:

Since the question is missing information, I will assume that you are doing an Ajax call in order to get a collection of links from the server and update a table.

I would suggest you to use jQuery and follow this previous answer on SO in order to display an animated loading spinner when a request is made and hide it when it is completed.

See the link: Jquery Ajax Loading image

Community
  • 1
  • 1
jpmorin
  • 6,008
  • 2
  • 28
  • 39
  • sorry bro its like (http://validator.w3.org/checklink) so when user will click on check its takes some time right to check links at that time i want that loading image.but its not ajax – hitarth Apr 09 '13 at 06:18
  • @hitarth I edited my answer according to your comment. I suggest to use the HttpResponse.Flush method. – jpmorin Apr 09 '13 at 06:50