How to change a web part’s behaviour when a page is in edit mode

WebPartManager wpm = WebPartManager.GetCurrentWebPartManager(this.Page);

if (wpm.DisplayMode.AllowPageDesign)
{
this.Controls.Add(new Literal(“edit mode”));
}
else
{
this.Controls.Add(new Literal(“not edit mode”));
}

Thanks to http://www.neilrichards.net/blog/?cat=12 I was able to use this to allow a user to append a querystring on to the URL to prevent a redirect.

Advertisements

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