怎么实现catch (Exception err)中抓取的错误以弹出窗口的形式提示? catch (Exception err){//这句代码如何写,实现弹出窗口提示错误?} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Response.Write("<script type=text/javascript>alert('提示错误!!!');</script>"); 我说的是把err.message信息以弹出窗口的形式显示出来。不知道该怎么写? form环境:System.window.form.MessageBox.show(err.Message); 忘了告诉大家,我用的环境是vs.net2005,用的是b/s架构 看不明白,蹭点分try{ int i = 0; i = 1 / i;}catch (Exception err){ MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } protected void Page_Load(object sender, EventArgs e) { try { int i = 0; i = 1 / i; } catch (Exception err) { ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), string.Format("window.alert('{0}')", err.Message), true); } } vs.net2005是不支持messagebox的,上面写的太复杂了。我说的是:if(){}catch(Exception err){//把err弹出窗口语句写在这里}finaly{} 我还没在任何开发语言中见过if ...catch的写法,如果你诚心提问就先准备好自己的测试环境不要浪费大家的时间 不好意思,写错了我想写的是:try() { } catch(Exception err) { //把err弹出窗口语句写在这里 } finaly { } try { } catch (Exception err) { ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), string.Format("window.alert('{0}')", err.Message), true); }finaly { } catch (Exception err){ MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } 问题是怎么弹出这个对话框错误信息都不重要//Page为本页面名//displayResult为要显示字符串Page.RegisterHiddenField("displayResult", displayResult);script = "<script language='javascript'>" + "window.onload=function(){ if(document.getElementById('displayResult').value != \"\") alert(document.getElementById('displayResult').value)} </script>";//进行显示Page.RegisterStartupScript("DisplayResult", script);这是基本的脚本 Response.Write("<script defer>alert('"+err.Message+"')</script>"); 感谢大家的热心,大家回答的时候最好是大家用过时正确的或则是自己能肯定是对的,在发帖,因为我看了大家的帖子,好像都不太对,vs.net2005不支持messagebox了,不知道大家了解不? Response.Write(" <script type=text/javascript>alert('" + err.Message + "'); </script>"); 基础问题 做论坛的时候,回帖的时候可以引用楼上的内容,这种效果怎么实现好? 求助大虾 WebBrower.Navigate与Thread.Sleep()之间的问题(高手请进) 邮件发送问题 asp.net TextBox的问题 (VS2005) 请问VS2003和2005是不是存在很大差别? 请教一个vs.net2003的问题, 不知道该如何表述,内详 关于货币样的字符串如何转换成数字 今天高兴,要分的来拿,来者有份 对windows应用程序窗体定位比较头疼,散100分向大家请教 数组问题费解!!!!!!!
System.window.form.MessageBox.show(err.Message);
try
{
int i = 0;
i = 1 / i;
}
catch (Exception err)
{
MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
{
try { int i = 0; i = 1 / i; }
catch (Exception err) {
ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
string.Format("window.alert('{0}')", err.Message), true);
}
}
我说的是:if()
{}
catch(Exception err)
{
//把err弹出窗口语句写在这里
}
finaly
{}
我想写的是:try()
{ }
catch(Exception err)
{
//把err弹出窗口语句写在这里
}
finaly
{ }
catch (Exception err) {
ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
string.Format("window.alert('{0}')", err.Message), true);
}
finaly
{ }
{
MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
错误信息都不重要//Page为本页面名
//displayResult为要显示字符串
Page.RegisterHiddenField("displayResult", displayResult);script = "<script language='javascript'>" +
"window.onload=function(){ if(document.getElementById('displayResult').value != \"\") alert(document.getElementById('displayResult').value)} </script>";
//进行显示
Page.RegisterStartupScript("DisplayResult", script);这是基本的脚本