[英]global.asax Application_Error reporting on original page
我想我知道答案,但是否可以讓 global.asax Application_Error 事件修改原始頁面上的文本框而不將客戶端移動到其他頁面? 類似於:Exception exp = Server.GetLastError().GetBaseException(); System.Data.SqlClient.SqlException sqlex;
if (exp is System.Data.SqlClient.SqlException) {
sqlex = (System.Data.SqlClient.SqlException) exp;
if (sqlex.Number == 50000) {
if (HttpContext.Current.CurrentHandler is Page) {
Page p = (Page) HttpContext.Current.CurrentHandler;
Control c = p.FindControl("ErrorText");
if (c != null && c is Label) {
((Label) c).Text = exp.Message;
Server.ClearError();
return;
}
}
}
}
如果你想這樣做,那么你應該使用頁面本身的“OnError”事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.