There are a number of situations where you may need to display information differently; when a page is being rendered in the editor, or, previewed. you may want to display different classes, or, even hide or show whole sections of code to allow content editors to have access to some additional back-end only features. In Episerver we have three modes available to us:
- Default - Normal web view
- Edit - In the editor
If we want to know if we're in preview mode we can use the 'CurrentContextMode'
In the real world, I've only ever done things differently in edit mode. For this reason, I'd recommend you use the PageEditing class rather than the 'CurrentContextMode'.
If the page is in edit mode, then it will be true. If you additionally want to get the editor Url for any page, you can use the GetEditUrl() method like: