你應該使用ClientScript.RegisterStartupScript
打開彈出窗口。
例
protected void btnSendRequest_Click(object sender, EventArgs e)
{
var myDbAccess = new DBAccess();
Event newEvent = (Event)Session["NewEvent"];
myDbAccess.SaveEvent(newEvent);
// Insert here a PopUp like "Successfully saved!"
var popupCode = @"<script>alert ('Javascript block of code executed')</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(),"myKey",popupCode);
}
你也可以通過在RegisterClientScriptBlock
方法的末尾使用如下
protected void btnSendRequest_Click(object sender, EventArgs e)
{
var myDbAccess = new DBAccess();
Event newEvent = (Event)Session["NewEvent"];
myDbAccess.SaveEvent(newEvent);
// Insert here a PopUp like "Successfully saved!"
var popupCode = @"alert ('Javascript block of code executed');";
ClientScript.RegisterClientScriptBlock(this.GetType(),"myKey",popupCode,true);
}
注過載的TRUE
值刪除您的字符串塊。
嘗試上面的代碼,讓我知道發生了什麼。
它給我這個錯誤: Errore:Sys.WebForms.PageRequestManagerServerErrorException: – Ciupaz 2012-02-14 13:03:51