Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
135
rated 0 times [  140] [ 5]  / answers: 1 / hits: 32562  / 14 Years ago, fri, july 16, 2010, 12:00:00

I am trying to call a javascript simple alert function when I catch an exception in my C# code as follows:



inside my function:



try
{
//something!
}
catch (Exception exc)
{
ClientScript.RegisterStartupScript(typeof(Page), SymbolError,
<script type='text/javascript'>alert('Error !!!');return false;</script>);
}


Is there another way I can do this, because this doesn't show any alert boxes or anything??


More From » c#

 Answers
34

It's because you'll get the error along the lines of:




Return statement is outside the
function




Just do the following, without the return statement:



ClientScript.RegisterStartupScript(typeof(Page), SymbolError, 
<script type='text/javascript'>alert('Error !!!');</script>);

[#96205] Wednesday, July 14, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ignacio

Total Points: 467
Total Questions: 128
Total Answers: 79

Location: Luxembourg
Member since Tue, Mar 14, 2023
1 Year ago
ignacio questions
;