I need to display a notification after an item was added through a custom visual web part.
If I try to use the TransferToSuccessPage(String), Sharepoint goes in error Thread Abort.
Tnx
|
I need to display a notification after an item was added through a custom visual web part. If I try to use the TransferToSuccessPage(String), Sharepoint goes in error Thread Abort. Tnx |
|||
|
|
Any transfer or redirect function called in the postback of a web page has the potential of throwing this error because the underlying implementation of these type of functions calls Response.End(), which causes page execution to abort. I think it's probably safe to eat the error...i.e. put a try/catch around the TransferToSuccessPage call. Alternatively, you could emit some javascript from the postback to display an alert or put something in the notification area, assuming we're talking about SP2010. UPDATE: Try this...
Change the SuccessText to whatever you want. If that doesn't work put a try/catch around the SPUtility.Redirect call...it's not the underlying transfer or redirect that's throwing an error, it's the Response.End that fires after it, so the redirect should still take place if you trap the error. |
|||||||||
|
|
|
I can't test this at the moment, but wouldn't this work?
Per Reflector, that does not execute a .End() and would allow the thread to finish its normal life cycle. |
|||
|
|