2012-03-20 46 views

回答

1

的EditorPart類:

public class YourCustomEditorPart:System.Web.UI.WebControls.WebParts.EditorPart{ 
    protected override void CreateChildControls() { 
     this.Title = "Editor Part Title Here"; 
     ... 
    } 
} 

告訴網絡的一部分,它應該使用這個編輯器的一部分,而不是歸因性能。

WebPart類:

public class YourWebPart:System.Web.UI.WebControls.WebParts.WebPart, IWebEditable { 
... 
EditorPartCollection IWebEditable.CreateEditorParts() { 
    // control the editorparts 
    List<EditorPart> editors = new List<EditorPart>(); 
    YourCustomEditorPart editorPart = new YourCustomEditorPart(); 
    editorPart.ID = this.ID + "_editorPart"; 
    editors.Add(editorPart); 
    return new EditorPartCollection(editors); 
    } 
... 
} 

退房以下系列的詳細信息。 (包括下載源代碼)

http://www.wictorwilen.se/Post/Web-Part-Properties-part-1-introduction.aspx

http://www.wictorwilen.se/Post/Web-Part-Properties-part-2-Editor-Parts.aspx

+0

答案幫助,但遺憾的是我不能投了,只是還沒有,因爲我沒有足夠的積分美譽:( – bkk 2012-03-21 03:46:08

+0

我應該感謝你感謝MinMin :) 還有一個問題,在標題部分TweetPart屬性中,節最小化圖標位於右側,與內置的「+」不一樣。有什麼辦法可以實現嗎? – bkk 2012-03-21 04:06:38

+0

標題標題的Html標記和css是從EditorPart類生成的。也許你可以重寫這個類的默認外觀。我不確定。如果您想了解更多,請查看此文檔。 (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.editorpart.aspx)。如果你有像'IE Developer toolbar'這樣的工具從頁面分析css和html,這將是非常有用的。 – 2012-03-21 06:11:28