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.

2 Responses to about EditModePanel in Sharepoint 2010

  1. Win says:

    Hi,

    Thank you for the post. Interesting changes in 2010… Why did they change this useful control from your point of view? I’m asking because I’m currently trying to see if EditModePanel control is a good component to generate two different design for a page layout on Moss 2007. Do you know how this control is working in the background? For example, if I create a page layout with 2 EditModePanel, in each panel I put render field controls but with several changes on the html side for having specific design in edit/display modes. Regarding the performance aspect, do you think this approach is valid? Or do I need to use this control very sparingly for fields which need to be shown only in edit mode…
    Thanks for your answer.

    • bpostaci says:

      They changed EditModePanel control beacuse of security issues.You can examine the background of this usercontrol using reflector. For performance aspect , the usercontrol has a little change in background i mean its almost same with older version except some security extentions. You can use it freely new version if you dont use anonymouse access in your site.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: