about EditModePanel in Sharepoint 2010


In Sharepoint 2010 the EditModePanel has working differently.

One of my friend asked me about a problem with EditModePanel does not render its content instead of PageDisplayMode property  has  already been set to “Display”.This problems only occurs with visitors.(In real who has not have “EditListItems” priviledges)  When i execute the code that he sent me yeah  he is absolutely right. After a couple of minutes in stunned than i used reflector and compared 2007&2010 Microsoft.Office.Sharepoint.Publishing.dll’s. Gotcha !!

Nice and friendly EditModePanel is not as known as it is.  calculateShouldRender() method has been changed

private void calculateShouldRender()

{

if (!ConsoleUtilities.CheckPermissions(SPBasePermissions.EditListItems))

{

this.shouldRender = false;

}

else

{

SPControlMode contextualFormModeFromPostedForm = ConsoleUtilities.GetContextualFormModeFromPostedForm();

if ((SPControlMode.Display == contextualFormModeFromPostedForm) && (PageDisplayMode.Display == this.PageDisplayMode))

{

this.shouldRender = true;

}

else if ((SPControlMode.Edit == contextualFormModeFromPostedForm) && (PageDisplayMode.Edit == this.PageDisplayMode))

{

this.shouldRender = true;

}

else

{

this.shouldRender = false;

}

}

this.Visible = this.shouldRender;

}

if you dont like this extra security code like me you may make your own EditModePanel.

Advertisements

About bpostaci
Escalation Engineer in Microsoft.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: