共用方式為


EditorPartChrome.RenderPartContents(HtmlTextWriter, EditorPart) 方法

定義

呈現 EditorPart 控制項的主要內容區域,但不包括區域首尾。

protected:
 virtual void RenderPartContents(System::Web::UI::HtmlTextWriter ^ writer, System::Web::UI::WebControls::WebParts::EditorPart ^ editorPart);
protected virtual void RenderPartContents (System.Web.UI.HtmlTextWriter writer, System.Web.UI.WebControls.WebParts.EditorPart editorPart);
abstract member RenderPartContents : System.Web.UI.HtmlTextWriter * System.Web.UI.WebControls.WebParts.EditorPart -> unit
override this.RenderPartContents : System.Web.UI.HtmlTextWriter * System.Web.UI.WebControls.WebParts.EditorPart -> unit
Protected Overridable Sub RenderPartContents (writer As HtmlTextWriter, editorPart As EditorPart)

參數

writer
HtmlTextWriter

接收 HtmlTextWriter 內容的 editorPart

editorPart
EditorPart

目前正在呈現的控制項。

範例

下列程式碼範例示範如何覆寫 RenderPartContents 方法,以將文字新增至編輯器元件。 如需執行範例所需的完整程式碼,包括裝載這些控制項的網頁,請參閱類別概觀的 EditorPartChrome 範例一節。

protected override void RenderPartContents(HtmlTextWriter writer, EditorPart editorPart)
{
    writer.AddStyleAttribute("color", "red");
    writer.RenderBeginTag("p");
    writer.Write("Apply all changes");
    writer.RenderEndTag();
    editorPart.RenderControl(writer);
}
Protected Overrides Sub RenderPartContents(ByVal writer As System.Web.UI.HtmlTextWriter, ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart)
    writer.AddStyleAttribute("color", "red")
    writer.RenderBeginTag("p")
    writer.Write("Apply all changes")
    writer.RenderEndTag()
    editorPart.RenderControl(writer)
End Sub

備註

方法 RenderPartContents 可讓您覆寫 的主體區域 editorPart 轉譯,同時讓頁首和頁尾轉譯為預設轉譯。

給繼承者的注意事項

您可以選擇性地覆寫 RenderPartContents(HtmlTextWriter, EditorPart) 方法。 如果是,您可以直接執行任何您想要的 editorPart 轉譯自訂,然後呼叫其 RenderControl(HtmlTextWriter) 方法。

適用於