2

I'm trying to switch personalisation scope for the current user:

    protected void lnkToggleMode_Click(object sender, EventArgs e)
    {
        try
        {
            var wpmgr = (SPWebPartManager)SPWebPartManager.GetCurrentWebPartManager(this.Page);
            wpmgr.Personalization.ToggleScope();
        }
        catch (Exception)
        {
            throw;
        }
    }

However, the ToggleScope method throws this exception:

'wpmgr.Personalization.ToggleScope()' threw an exception of type 'System.Threading.ThreadAbortException' base {System.SystemException}: {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.} ExceptionState: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

Any thought?

FYI, the wpmgr.Personalization.CanEnterSharedScope property is returning true

1 Answer 1

0

From your question, I can't tell why you're not using an SPLimitedWebPartManager but the standard .net webpartmanager:

If you can get hold of either the SPWeb / SPFile object you're working on you could try calling mySPFileObject.GetLimitedWebPartManager which takes a personalizationScope enum as a parameter.

MSDN: SPFile:GetLimitedWebPartManager

1
  • I want to switch the context of the whole page. What you are mentioning only allows to manipulate the page's webpart.
    – Steve B
    Commented Feb 25, 2014 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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