LoadClientScriptMessage
功能不起作用,而Response.Redirect("SamePage.aspx");
效果不錯!JavaScript與c#無效
if (command2.ExecuteNonQuery() == 0)
{
LoadClientScriptMessage("Something went wrong!");
}
else
{
LoadClientScriptMessage("It is OK!");
Response.Redirect("SamePage.aspx");
}
這裏是LoadClientScriptMessage
實現:
private void LoadClientScriptMessage(string message)
{
StringBuilder script = new StringBuilder();
script.Append(@"<script language='javascript'>");
script.Append(@"alert('" + message + "');");
script.Append(@"</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script.ToString());
}
要顯示警報和重定向用戶,並抱怨說,這是行不通的重定向? –
或者當條件評估爲真時,它是第一次調用嗎? – Abhitalks