2012-09-19 28 views
0

我正在開發c#中的asp.net項目。在我的應用程序中,我使用Devexpress htmleditors,我需要自定義conetxtmenu。所以我試圖從代碼後面添加conextmenu項目,但我得到以下錯誤。ASPxHtmlEditor中的ContextMenu

1.DevExpress.Web.ASPxHtmlEditor.ASPxHtmlEditor.ContextMenuItems'不可訪問由於其保護級別

2,屬性或索引‘DevExpress.Web.ASPxHtmlEditor.ASPxHtmlEditor.ContextMenuItems’不能在此上下文中使用因爲獲取訪問者無法訪問

而這個我試着在代碼後面。

htmlEdtBody.ContextMenuItems.Insert(0, new HtmlEditorContextMenuItem("Add Title...", "AddTitle")); 

任何人都知道是什麼原因?

謝謝

回答

1

我建議你去通過ASPxHtmlEditor的演示 - Features - Context Menu,有一個很好的演示,可以幫助您瞭解這將如何工作。

首先設置ASPxHtmlEditorSettings.AllowContextMenu屬性。您可能需要登錄ASPxClientHtmlEditor.ContextMenuShowing事件。 ASP.NET HTML Editor Control

參考 - Context Menu

protected void Page_Load(object sender, EventArgs e) { 
    if (!IsPostBack) { 
      MyHtmlEditor.ContextMenuItems.CreateDefaultItems(); 
      MyHtmlEditor.ContextMenuItems.Insert(0, new HtmlEditorContextMenuItem("Add Title...", "AddTitle")); 
      MyHtmlEditor.ContextMenuItems.Insert(1, new HtmlEditorContextMenuItem("Change Title...", "ChangeTitle")); 
      MyHtmlEditor.ContextMenuItems.Insert(2, new HtmlEditorContextMenuItem("Remove Title", "RemoveTitle")); 
    } 
} 

這一點 - ASPxGridView - Editing using popup menu and ContextMenu event可以幫助你..

+0

謝謝。我認爲我的DLL中存在問題。我使用了DevExpress.Web.ASPxHtmlEditor.v11.1.dll。但在演示中,他們使用DevExpress.Web.ASPxHtmlEditor.v12.1.dll。我認爲問題在那裏。 – Poorna

+0

很高興你找出問題..祝你有美好的時光.. –