如何显示异常消息 [英] how to display an exception message
问题描述
大家好
我正在Telerik Mvc3中进行批量编辑.通过单击网格中的savechanges按钮,它使用ajax选项为此数据库更新数据库.如果在保存记录时发生任何错误,则会抛出异常消息,但我想在我的视图中显示该异常消息页面我尝试了这种编码,但无法正常工作
功能 OnSuccess(e){
var 容器= $(" );
如果(例如,HasError == < false )
{
var grid = $(" ).data(" );
grid.rebind();
alert(" );
}
其他
{
showMessage(e.Message.MessageCode,e.Message.Message,e.Message.MessageType,容器);
alert(" );
}
}
我在OnSuccess事件上调用了此函数.警报消息发生错误"即将到来,但显示消息不起作用.表示MessageCode,message和messsagetype也具有值
(" ); 如果(例如,HasError == < false ) { var grid =
(" ).data(" ); grid.rebind(); alert(" ); } 其他 { showMessage(e.Message.MessageCode,e.Message.Message,e.Message.MessageType,容器); alert(" ); } }
我在OnSuccess事件上调用了此函数.警报消息发生错误"即将到来,但显示消息不起作用. MessageCode,message和messsagetype也具有值
如果您查看上面代码中应用的代码标记,将会发现它不知道如何处理它.尝试警报:
警报(' 错误:' + e.Message.Message + ' (' + e.Message.MessageCode + ' )');
祝你好运!
Hi all
I am doing batch editing in telerik mvc3.By clicking savechanges button in the grid it updates the database for this am using ajax options.if any error occurred while saving records an exception message is throwing but I want to display that exception message in my view page i tried this coding but not working properly
function OnSuccess( e ) { var container = $(".msg_container"); if(e.HasError==false) { var grid = $("#grdHolidays").data("tGrid"); grid.rebind(); alert("Saved"); } else { showMessage(e.Message.MessageCode, e.Message.Message, e.Message.MessageType ,container); alert("Error occurred"); } }
I had called this function on OnSuccess event.Alert message "Error occurred" is coming but show message is not working. that MessageCode,message and messsagetype are having values also解决方案(".msg_container"); if(e.HasError==false) { var grid =
("#grdHolidays").data("tGrid"); grid.rebind(); alert("Saved"); } else { showMessage(e.Message.MessageCode, e.Message.Message, e.Message.MessageType ,container); alert("Error occurred"); } }
I had called this function on OnSuccess event.Alert message "Error occurred" is coming but show message is not working. that MessageCode,message and messsagetype are having values also
If you look at the code markup applied in your code above you''ll see that the it doesn''t know what to do with it. Try an alert:
alert('Error: ' + e.Message.Message + ' ('+ e.Message.MessageCode +')');
Good luck!
这篇关于如何显示异常消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!