Using the episerver api how do you determine if you are in edit mode if not? And no I do not want to determine this by looking at querystring.
The reason I am wanting this is because I want to assign role permissions to property types, not just at page type level.
There is currently no other way to determine if a page is in episervers edit mode than looking at the request. You can always investigate if the current page is read only or not to see if the page is beeing edited though. Another aproach is to use a control adapter to hide certain properties for a user. Here is some code to get started. You also have to register the control adapter in the app_browsers\adaptermappings.browser file by adding the following row:
Here the sample adapter that hides the property for all users not beeing member of the group "nonexistingrole":
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EPiServer.Web.PropertyControls.Adapters;
using EPiServer.Security;
namespace EPiServer.Test
{
public class PropertyControlSecurityAdapter : PropertyDataControlAdapter
{
public override bool DisplayEditUI
{
get
{
return EPiServer.Security.PrincipalInfo.Current.Principal.IsInRole("nonexistingrole");
}
}
}
}
Good luck!
Linus Ekström
EPiServer Development Team
Hi Sam,
have you tried checking the url? e.g.
if (HttpContext.Current.Request.UrlReferrer != null)
{
mode = Regex.IsMatch(HttpContext.Current.Request.UrlReferrer.LocalPath, "/admin/|/edit/", RegexOptions.IgnoreCase);
}
return mode;
Hi Sam,
have you tried checking the url? e.g.
if (HttpContext.Current.Request.UrlReferrer != null)
{
mode = Regex.IsMatch(HttpContext.Current.Request.UrlReferrer.LocalPath, "/admin/|/edit/", RegexOptions.IgnoreCase);
}
return mode;