How to display messagebox after timeout in Timer1_Tick

Posted by Dn2010 under ASP.NET on 1/18/2011 | Points: 10 | Views : 3639 | Status : [Member] | Replies : 4
hi friends,

How to display messagebox after timeout in Timer1_Tick

i give the these belowcode,but its not working,

Response.write("<script>alert('Time is Over')</script>");
Response.Write("<script>window.location.href('result.aspx')</script>");


please give the solution for it.

protected void Timer1_Tick(object sender, EventArgs e)
{
Session["time"] = Convert.ToInt16(Session["time"]) - 1;
if (Convert.ToInt16(Session["time"]) <= 0)
{
lbl_time.Text = "TimeOut!";
//Response.Write("<script>alert('Time Over')</script>");
//Response.Write("<script>window.location.href('result.aspx')</script>")
}
else
{
totalSeconds = Convert.ToInt16(Session["time"]);
seconds = totalSeconds % 60;
minutes = totalSeconds / 60;
time = minutes + ":" + seconds;
lbl_time.Text = time;
}

thanks.




Responses

Posted by: Karthikanbarasan on: 1/18/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,
Use javascript alert to display Message box in asp.net
eg
Response.Write("<script>alert('Time is over')</script>");

Thanks
Karthik
www.f5Debug.net

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/19/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi DN2010
if u want to genrate diloag box on when timer1 time out so u write code inside Timer1_onload

in a source

<asp:Timer ID="Timer1" OnLoad="Timer1_onload" runat="server">
</asp:Timer>
on code
protected void Timer1_Onload(object sender, EventArgs e)

{
Response.Write("<script>alert('Time is over')</script>");
}

Thanks & Regard's
Prabhakar

Best Regard's
Prabhakar

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dn2010 on: 1/19/2011 [Member] Starter | Points: 25

Up
0
Down
thanks,

its working but error returns on runtime.

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/20/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi, dn2010


ok.. if it's working so whats the error on run time say it.


Thanks & Regard's
Prabhakar

Best Regard's
Prabhakar

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response