string text = "ok sa you na ra";
Response.Write("<script>window.alert('" + s + "');</script>");
注: 无论代码写在哪里,最后生成的HTML代码,输出的字符串都在整个页面的最上面,经常会导致整个页面显示空白,这是因为,在您点击alert()确定按钮之前,下面的代码尚未执行。Response.Write("<script>window.alert('" + s + "');</script>");
string text = "ok sa you na ra";
Page.RegisterStartupScript("keyName", "<script>window.alert('" + s + "');</script>");
注: 当然,该语句可以解决上面的问题,即:代码写在哪里,就生成在哪里!
Page.RegisterStartupScript("keyName", "<script>window.alert('" + s + "');</script>");