Saturday, January 21, 2023

AJAX toolkit timer ASP.NET C# ONTICK - Clock time - time changing every second

ASPX PAGE

   <form id="form1" runat="server">

       

    <asp:ScriptManager runat="server"  OnAsyncPostBackError=></asp:ScriptManager>

    <asp:UpdatePanel runat="server">

    <ContentTemplate>

    <asp:Timer ID="Timer1" runat="server" OnTick="getTime" Interval="1000">

    </asp:Timer>

    <asp:Label runat="server" ID="lbl" />

    </ContentTemplate>

    </asp:UpdatePanel>

    </form>

ASPX.CS

 protected void getTime(object sender, EventArgs e)

    {

         lbl.Text= DateTime.Now.ToString();

//Response.redirect(DateTime.Now.ToString()); /*This will work on refresh of page every second, ie without using update panel, it will work*/



    }


For updatepanel we have to create lable, if we use reponse.redirect it will show error



No comments:

Post a Comment