Access Denied Error in SharePoint
Hi Friends,I have written below code to create a dynamic control ; its working fine for site admin , contribute permissions users ... however its giving access denied error for visitor groups ? any idea and solution ? i tried with elevated privileges and Catchaccess denied exception , still no luck...
erroring in this line this.Controls.Add(this.htmlEditor);
SPSecurity.RunWithElevatedPrivileges(delegate()
{
bool originalCatchValue = SPSecurity.CatchAccessDeniedException;
SPSecurity.CatchAccessDeniedException = false;
SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
if (ribbon != null)
{
ribbon.TrimById("Ribbon.EditingTools.CPEditTab.Layout");
ribbon.TrimById("Ribbon.EditingTools.CPEditTab.EditAndCheckout");
}
this.htmlEditor.Field = new RichHtmlField();
this.htmlEditor.Field.ControlMode = SPControlMode.Edit;
this.htmlEditor.Field.EnableViewState = true;
this.htmlEditor.Field.AllowReusableContent = false;
this.htmlEditor.Field.MinimumEditHeight = this.MinimumEditHeight;
this.htmlEditor.Field.PopupEditorMode = true;
this.htmlEditor.Field.HasInitialFocus = true;
this.htmlEditor.Field.UseInlineStyle = true;
this.Controls.Add(this.htmlEditor); // access denied error for visitors but it works for contribute permission users
base.OnInit(e);
SPSecurity.CatchAccessDeniedException = originalCatchValue;
});
Thanks,
Kiran