开发者

Message of Javascript exception in C#

开发者 https://www.devze.com 2022-12-24 18:46 出处:网络
i\'m doing some unit tests in Silverlight. Therefore i\'m invoking some javascript functions. i\'d like to know how to get the message of the exception thrown in javascript开发者_如何学Python.

i'm doing some unit tests in Silverlight. Therefore i'm invoking some javascript functions. i'd like to know how to get the message of the exception thrown in javascript开发者_如何学Python. Is this possible?

Thanks! Peter


Here you go:

try {

foo();

} catch (e) {

alert("An exception occurred in the script. Error name: " + e.name 
+ ". Error message: " + e.message); }

<Edit> Sorry, I just realized you need this in C# code. In order to do that, you'll have to take this data and pass it into your C# code somehow, whether by AJAX or form submission or something.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号