在普通ASP.NET应用中,使用内置对象Response.Write方法可以直接输出JavaScript脚本的alert语句,并以客户端对话框的形式弹出,代码如下:

Response.Write("<script>alert('操作成功!');</script>");

但是在ASP.Net AJAX 应用程序中,如果使用上述代码会弹出一个错误对话框,

解决的方法是使用ScriptManager类的RegisterStartupScript方法来输出UpdatePanel控件更新时需要弹出的对话框,在AJAX环境中弹出对话框的具体代码如下:

ScriptManager.RegisterStartupScript(UpdatePanel1,typeof(UpdatePanel), "scriptname", "alert('这是在AJAX环境中弹出对话框!');", true);

相关文章:

  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-02-08
  • 2022-02-15
  • 2021-10-03
  • 2021-10-29
相关资源
相似解决方案