<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()); }