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

In relation to my previous question, I've found some help on the internet that describes how to accomplish connecting web parts in the code-behind file of a site page.

Following this, I have the following code in my Page_Load method:

WebPartManager wpm = SPWebPartManager.GetCurrentWebPartManager(Page);
System.Web.UI.WebControls.WebParts.WebPart wpBdi = wpm.WebParts["g_332ad567_4e06_4f13_aaf4_1823b9e10c25"];
System.Web.UI.WebControls.WebParts.WebPart wpQsf = wpm.WebParts["g_17cd7e1d_999f_425b_b62f_4cb2e8ceac7f"];
ProviderConnectionPointCollection pcpc = wpm.GetProviderConnectionPoints(wpQsf);
ConsumerConnectionPointCollection ccpc = wpm.GetConsumerConnectionPoints(wpBdi);
ProviderConnectionPoint pcp1 = wpm.GetProviderConnectionPoints(wpQsf)["ITransformableFilterValues"];
ConsumerConnectionPoint ccp1 = wpm.GetConsumerConnectionPoints(wpBdi)["BDWP Item"];
TransformableFilterValuesToEntityInstanceTransformer t =
    new TransformableFilterValuesToEntityInstanceTransformer();
WebPartConnection conn = wpm.ConnectWebParts(wpQsf, pcp1, wpBdi, ccp1, t);

However, when I try to access this page, I get the following error:

Cannot complete this action.

Please try again.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:

Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Cannot complete this action.

Please try again.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[WebPartPageUserException: Cannot complete this action.
Please try again.]
Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChangesCore(SPLayoutProperties layoutProperties, Boolean httpGet, Boolean saveCompressed, Boolean skipRightsCheck, Boolean skipSafeAgainstScriptCheck, WebPartTypeInfo& newTypeId, Byte[]& newAllUsersProperties, Byte[]& newPerUserProperties, String[]& newLinks) +5423
Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChangesOnGet(SPLayoutProperties layoutProperties, Boolean skipRightsCheck, Boolean skipSafeAgainstScriptCheck) +232
Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChangesInternal(SPLayoutProperties layoutProperties, Boolean skipRightsCheck, Boolean skipSafeAgainstScriptCheck) +26847349
Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChanges(SPLayoutProperties layoutProperties, Boolean skipRightsCheck, Boolean skipSafeAgainstScriptCheck) +367
Microsoft.SharePoint.WebPartPages.SPWebPartPersonalization.Save() +369
System.Web.UI.WebControls.WebParts.WebPartManager.OnPageSaveStateComplete(Object sender, EventArgs e) +307
System.Web.UI.Page.OnSaveStateComplete(EventArgs e) +11070062
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4039

The only thing mentioning this error that I can find on Google is this Microsoft knowledgebase article which suggests using impersonation would resolve this. However, this does not have any effect on the result.

I can see from running the page in the debugger that it gets through the entire Page_Load method without throwing an exception - so what am I doing wrong?

share|improve this question
add comment

1 Answer

If i'm not mistaken your web parts are NOT inheriting from the WebPart class in the SharePoint namespace, but rather from the general ASP.NET web part, right??

If that is the case, to my knowledge one of the major differences between these WebPart base classes is that only SharePoint-based web parts allow for Connections in the SharePoint Web part zones.

share|improve this answer
    
They are standard SP web parts. Both inherit from Microsoft.SharePoint.WebPartPages.WebPart (which itself inherits from System.Web.UI.WebControls.WebParts.WebPart) –  TZHX Aug 7 '12 at 8:02
add comment

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.