Monday 7 October 2013

Ajax UpdateProgress Example in ASP.NET using C#.NET

Hi friends, in this article I will explain about Ajax UpdateProgress Example in ASP.NET using C#/VB.NET.
I already explained in the previous articles about How to select all the Checkboxes in Gridview by clicking on Checkbox in HeaderText in ASP.NET using JavascriptHow to select all the Checkboxes in Gridview by clicking on Checkbox in HeaderText in ASP.NET using Javascript and Ajax UpdatePanel Control Example in ASP.NET
In ASP.NET:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>UpdateProgress Example</title>
    <style type="text/css">
    #UpdatePanel1 {
      width:500px; height:150px;
     }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <fieldset>
                <legend>Time</legend>
                <asp:Label ID="Label1" runat="server" Text=''></asp:Label><br />
                <asp:Button ID="GetTime" runat="server" Text="Button" OnClick="GetTime_Click" />               
                <asp:GridView ID="GridView1" runat="server">
                </asp:GridView>
                </fieldset>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server">
            <ProgressTemplate>
            <img src="images/loading_image.gif" alt=""/>
                Processing...
            </ProgressTemplate>
        </asp:UpdateProgress>

    </div>
    </form>
</body>
</html>


In C#.NET:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UpdateProgress : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "Initial page rendered at" + DateTime.Now.ToString();
    }
    protected void GetTime_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(4000);
        Label1.Text = "Page refreshed at "DateTime.Now.ToString(); 
    }
}



The output of the above code as shown in the below figure.

No comments:

Post a Comment

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.