DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 17 Aug 2007 19:17:10 -0400,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Monty am
          2    (Walter Wang [MSFT])
          3    Monty am


Ajax - "exception has been thrown by the target of an invocation"   
[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
Date:Fri, 17 Aug 2007 19:17:10 -0400   Author:  

RE: Ajax - "exception has been thrown by the target of an invocation"   
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.
Date:Mon, 20 Aug 2007 11:10:30 GMT   Author:  

Re: Ajax - "exception has been thrown by the target of an invocation"   
Perfect, thanks again Walter!
Date:Mon, 20 Aug 2007 23:06:45 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us