---
title: "asp.net中执行到Response.write(\"xx\");这段语句时出现下面的情况，请问如何改正？"
author: "winzenghua"
date: "2010-12-21T17:11:00Z"
tags: []
slug: "asp-net-response-write-xx"
draft: false
lastmod: "2010-12-21T17:11:00Z"
id: 948932
url: "https://java4gis.iteye.com/blog/948932"
---

```
在放置了UpdatePanel时，即便是设置了PostBackTrigger 也无法Response.Write();正常情况下，微软推荐我们是这么用的：
                string scripts = "<script>alert('弹出提示框！');</script>";
                ClientScriptManager csm = Page.ClientScript;
                csm.RegisterClientScriptBlock(this.GetType(), "sss", scripts, false);
                //csm.RegisterStartupScript(this.GetType(),"sss",scripts,false);

如果还不行你就用专门针对UpdatePanel控件的：
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('房间号不存在！');", true); 
你只需将alert('房间号不存在！');改成你输出的脚本即可！
```

Hi, When you use update panel then you can not call javascript like this .. Try Following Code, string CloseWindow; CloseWindow = "alert('Hello World')"; ScriptManager.RegisterStartupScript(UpdatePanelID,UpdatePanelID.GetType(), "CloseWindow", CloseWindow, true);