你应该使用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