Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
I'm using Sharepoint 2010 –  Albevi Aug 12 '11 at 15:19

2 Answers 2

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...

SPUtility.Redirect("success.aspx", SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current, HttpUtility.UrlEncode("SuccessText=It worked!"));

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.

share|improve this answer
    
So I have not a server side solution? –  Albevi Aug 12 '11 at 15:20
    
Read update to answer... –  Rob D'Oria Aug 12 '11 at 16:07
    
this solution is really ugly –  Albevi Aug 12 '11 at 16:48
    
what do you mean? –  Rob D'Oria Aug 12 '11 at 16:51

I can't test this at the moment, but wouldn't this work?

Response.Redirect(targetUrl, false)

Per Reflector, that does not execute a .End() and would allow the thread to finish its normal life cycle.

share|improve this answer
    
As said previously you can do this after an item.Update(); –  Albevi Aug 14 '11 at 6:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.