<head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function timedMsg() { var t=setTimeout("alert('good morning!')",6000); } </script> </head>
protected void Button1_Click(object sender, EventArgs e) { StringBuilder script = new StringBuilder(); script.Append("<script type=\"text/javascript\">"); script.Append("timedMsg();"); script.Append("</script>"); Page.ClientScript.RegisterClientScriptBlock(typeof(object), "JavaScriptBlock", script.ToString()); }
<head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function timedMsg(var x) { var t=setTimeout("alert('I am displayed after 3 seconds!')",x); } </script> </head>
protected void Button1_Click(object sender, EventArgs e) { int x = 6000; StringBuilder script = new StringBuilder(); script.Append("<script type=\"text/javascript\">"); script.Append("timedMsg(x);"); script.Append("</script>"); Page.ClientScript.RegisterClientScriptBlock(typeof(object), "JavaScriptBlock", script.ToString()); }
int timeOut = 6000; Page.ClientScript.RegisterStartupScript(this.GetType(), "javaScript", string.Format("javascript:timedMsg('{0}');", timeOut), true);
Replace var x by x<br /> <head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function timedMsg(x) { var t=setTimeout("alert('I am displayed after 3 seconds!')",x); } </script> </head>
script.Append("timedMsg(x);");
script.Append("timedMsg("+ x +");");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)