【发布时间】:2015-01-12 10:47:31
【问题描述】:
我正在尝试在为我的表单视图插入项目时进行一些错误处理。如果有人忘记在教程部分输入一个值,错误消息将检测到它为 null 并弹出它为 null。但是,我的视觉工作室无法识别 Exception 或 ExceptionHandled。错误是没有异常的定义。我搜索了高低,我不知道问题是什么。任何想法将不胜感激。
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
{
if (e.Exception != Null)
{
string msg = "";
if (e.Exception.Message.Containts("NULL"))
{
msg = "Tutorial Section cannot be empty.";
}
else
msg = "unknown";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "window.setTimeout(\"alert('" + msg + "')\",0);", true);
e.ExceptionHandled = true;
}
}
【问题讨论】:
-
你所说的我猜是指验证而不是错误处理。
-
不是这样。我只是想知道为什么无法识别 e.Exception。
-
@NegarNegaru 它根本不存在。 FormViewInsertEventArgs Class
-
我明白了。我假设因为它存在于 listview 中,它也应该存在于 formview 中。谢谢。
标签: c# asp.net exception-handling