Microsoft JScript 运行时错误: 'document.getElementById(...)' 为空或不是对象


在项目中遇到一个很头疼js问题。

第一种方法

string strJS = "<script language='javascript' type='text/javascript'>AlertAndReturn('保存成功');</script>";
ScriptManager.RegisterStartupScript(this, this.GetType(), "client", strJS, false);


第二种方法
string strJS = "AlertAndReturn('保存成功');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "client", strJS, true);

发现,第一种方法成功,第二种方法老是弹出脚本问题(在IDE的环境下)

最后跟踪,ScriptManager.RegisterStartupScript(this, this.GetType(), "client", strJS, true);生成的脚本

<script  type='text/javascript'> 少了language='javascript'这一截。

原文地址:https://www.cnblogs.com/Kazaf/p/2760748.html