Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Ajax - "exception has been thrown by the target of an invocation"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Monty - 18 Aug 2007 00:17 GMT
[ASP.Net 2005, WinXP SP2, IE7]

I have a GridView in an update panel, and the GridView has an
ObjectDataSource. Under certain conditions the Object that is the
ObjectDataSource will throw an exception with a specific error message, but
on the client side the only error message displayed is "exception has been
thrown by the target of an invocation". I would like the error message on
the client to show the error description the object provides when it throws
the error. Is there any way to do this? For clarification, I know exactly
why the exception is being thrown, and it should be thrown, so I'm not
trying to debug that, I'm just trying to figure out how to get the error
message alert box shown on the client side to show the actual InnerException
message instead of  "exception has been thrown by the target of an
invocation".  TIA
Walter Wang [MSFT] - 20 Aug 2007 12:10 GMT
Hi Monty,

You can handle the event "AsyncPostBackError" of the ScriptManager instance
on the WebForm to return a custom message whatever you want:

   protected void ScriptManager1_AsyncPostBackError(object sender,
AsyncPostBackErrorEventArgs e)
   {
       if (e.Exception != null && e.Exception.InnerException != null)
       {
           ScriptManager1.AsyncPostBackErrorMessage =
e.Exception.InnerException.Message;
       }
   }

Above code will correctly show the real exception's message.

Hope this helps.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Monty - 21 Aug 2007 04:06 GMT
Perfect, thanks again Walter!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.