System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(),"", "alert('11')", true);这句我放在aspx没有问题
但放在DBUtility的cs里面就提示ScriptManager没有引用。
网上说的添加system.web.extention我都添加了,但问题还存在。
但放在DBUtility的cs里面就提示ScriptManager没有引用。
网上说的添加system.web.extention我都添加了,但问题还存在。
你添加了么
System.Web.UI已经添加了,会报错
<asp:ScriptReference Assembly="xxxxx.Web.LocalizingScriptResources" Name="xxx.Web.LocalizingScriptResources.xx.js" />
</Scripts>
public static void Alert(string pMessage) {
//此处省略参数处理,请自行添加
string _JString = "alert('"+pMessage+"');";
Page _thisPage = (Page)HttpContext.Current.Handler;
string _JSKey = Guid.NewGuid().ToString();
System.Web.UI.ScriptManager.RegisterStartupScript(
_thisPage, _thisPage.GetType(), _JSKey, _JString, true);
}//我们假设类库名称jsHelper,在任何后台cs文件中也可以使用
jsHelper.Alert("11");
不过,我们实际上是禁止在业务代码中引用UI层的全局对象的,
这种情况都是先抛出自定义的特定异常,然后再应用程序的边界处:UI报告或者处理这个异常