How to use JQuery setTimeout function in Asp.Net C# VB.Net

The setTimeout() method invoke or calls a function to evaluate an expression after a specified number of milliseconds. The function is executed only once. But you can repeat by setInterval() method. You can Use the clearTimeout() method to prevent the function to run. Here I am going to explain setTimeout() method in JQuery code. To do the example I am using a Paragraph & and a Button. When user click on the Button the Paragraph block will be Sliding UP after 2 seconds.

Basic Syntax of setTimeout() Method:

setTimeout(function() {
      // Do something after 2 seconds
}, 2000);

Objective/Outcome:
How to use JQuery setTimeout function - Asp.Net Csharp VB.Net

The HTML Code:

    <p style="background-color:Lime;font-weight:bold;width:200px;height:200px">
    This ia a test<br />
    This ia a test<br />
    This ia a test<br />
    This ia a test<br />
    This ia a test<br />
    This ia a test<br />
    This ia a test<br />
    This ia a test<br />
    </p>
    <asp:Button ID="Button1" runat="server" Text="Click to Start setTimeout" /><br />

JQuery setTimeout() method Code Example:

<script type="text/javascript">
    $(document).ready(function () {
        $('#<%=Button1.ClientID %>').click(function () {
            setTimeout(function () {
                $("p").slideUp();
            }, 2000);
            return false;
        });
    });  
    </script>

Download Code Example C#        Download Code Example VB.Net

Posted in .Net, Asp.net, C#, Client, JQuery, VB.Net

Leave a Reply

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

     

*