0

i want to use timer in my pages..below is the code that i had used..
its working fine when i used it with a new page..but when i used it with my master page and run in browser it will only show the time..i had to refresh it every time to see the next time...plz help me with this....

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>
<br />
<asp:Label ID="Label1" runat="server" style="color: #FFFFFF" ></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID ="Timer1" EventName ="Tick" />
</Triggers>

</asp:UpdatePanel>
<br /><br />

<asp:Timer ID="Timer1" runat="server" Interval ="60" >
</asp:Timer>

............................................


code c#

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = System.DateTime.Now.ToString();
}


protected void Timer1_Tick1(object sender, EventArgs e)
{
Label1.Text = System.DateTime.Now.ToString();
}

}

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rohitmanhas_12
0

Here is your solution..

default.aspx

<asp:ScriptManager ID="ScriptManager1" runat="server" />      
<asp:Timer ID="Timer1" runat="server" Interval="50" OnTick="Timer1_Tick" />        
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" />
        </Triggers>
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>

default.aspx.cs

protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToString("hh:mm:ss");
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToString("hh:mm:ss");
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.