在页面中, try...catch中, 可以用RegisterStartupScript产生一个对话框, 显示出现的错误或者其他信息, 为什么在类中,怎么也找不到这个方法呢, 我已经把页面中命名空间全给加进来了, 是怎么回事呀, 是在类中, 不能用, 还是我丢了什么东西呀?
如果在类中, 不能使用这种方式,那用什么方法向用户直观提示错误呀?
谢谢各位。
如果在类中, 不能使用这种方式,那用什么方法向用户直观提示错误呀?
谢谢各位。
解决方案 »
- 关于网站主页图片的管理
- 高分请教。。。关于FileUpload控件!
- 编译上传到服务器问题~
- 请教:这段数据操作代码con怎么关闭啊
- 为什么GridView不能调用存储过程去更新?
- 怎么在Button控件的问题?
- 在使用吴旗娃的控件时,pager.CurrentPageIndex的值总是为零
- jquery ajax本地有数据返回,上传到服务器也有数据返回.但是现在是数据过了一段时间就没有数据了.有没有人知道什么原因啊?
- 【Help】DataGrid中如何做到在客户端可调整列的宽度?
- 哪位大虾能给偶一份用DataGrid取大类然后取与大类相关的小类的代码!
- 九万火急的问题
- 如何在datagrid的绑定语句中再插入查询语句?
{
// If this is the first time a page has called this method then
string locMsg = ResourceReader.readMsg(sMessage);
if( !m_executingPages.Contains( HttpContext.Current.Handler ) )
{
// Attempt to cast HttpHandler as a Page.
Page executingPage = HttpContext.Current.Handler as Page; if( executingPage != null )
{
// Create a Queue to hold one or more messages.
Queue messageQueue = new Queue(); // Add our message to the Queue
messageQueue.Enqueue(locMsg); // Add our message queue to the hash table. Use our page reference
// (IHttpHandler) as the key.
m_executingPages.Add( HttpContext.Current.Handler, messageQueue ); // Wire up Unload event so that we can inject
// some JavaScript for the alerts.
executingPage.Unload += new EventHandler( ExecutingPage_Unload );
}
}
else
{
// If were here then the method has allready been
// called from the executing Page.
// We have allready created a message queue and stored a
// reference to it in our hastable.
Queue queue = (Queue) m_executingPages[ HttpContext.Current.Handler ]; // Add our message to the Queue
queue.Enqueue(locMsg);
}
}
非要在类中实现也可以这样写
System.Web.HttpContext.Current.Response.Write("<script language=javascript>alert('"+ex.Message+"');</script>");
你自己写的类文件,不是继承自system.web.ui.page,所以类不具有RegisterStartupScript方法
==========================================
正解