TIP: Create „edit this page“ link and edit page without accessing administrative area

TIP: Create „edit this page“ link and edit page without accessing administrative area

Posted on December 17, 2007 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

In this post I'll explain how to create a functionality that will let you access the edit mode of the page while browsing. I'll also provide you with the code you'll need to implement this.

Basic idea

Edit this page control

If you've paid attention to the url while in edit mode of a page, you may have noticed that the url is exactly the same as the url of page when it's not in edit mode, with one important exception. Namely, querystring „cmspagemode=edit“ is appended to the url. So, to achieve our desired functionality, we simply need to create a link that will point to page itself and add that querystring at the end.

Implementation

While there is truly many different ways you can do this, we’ll go with the simplest one. We’ll create a user control that will consist only of one HyperLink control. The text of that HyperLink we’ll set to “Edit this page”. In the Page_Load method of that page we’ll set the url of the link to the current url plus the querystring for edit mode.

Also, because we don’t want this link to be visible to anyone browsing our page, we’ll make it visible only to authenticated users with the permission to modify the page in question.

And that’s it. While this, I believe, is a neat trick, it’s only a trick. In Sitefinity 4.0 (see roadmap) a robust and streamlined “browse-and-edit” feature will be implemented in Sitefinity.

>> DOWNLOAD “EditThisPage” user control.

progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation