ControlDesigner.GetEmptyDesignTimeHtml 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取 HTML 標記,以在設計階段呈現在執行階段沒有視覺表示的 Web 伺服器控制項。
protected:
virtual System::String ^ GetEmptyDesignTimeHtml();
protected virtual string GetEmptyDesignTimeHtml ();
abstract member GetEmptyDesignTimeHtml : unit -> string
override this.GetEmptyDesignTimeHtml : unit -> string
Protected Overridable Function GetEmptyDesignTimeHtml () As String
傳回
HTML 標記,用來在設計階段呈現沒有視覺表示的控制項。 預設值是一個包含元件類型和識別碼的矩形。
範例
下列程式碼範例示範如何在自訂控制項設計工具中覆寫 GetDesignTimeHtml 方法。 Text
如果相關聯控制項的 屬性是空的,方法會 GetDesignTimeHtml 呼叫 GetEmptyDesignTimeHtml 方法。 否則, GetDesignTimeHtml 方法會建立和轉譯 Hyperlink
控制項。
public override string GetDesignTimeHtml()
{
if (simpleControl.Text.Length > 0)
{
string spec = "<a href='{0}.aspx'>{0}</a>";
return String.Format(spec, simpleControl.Text);
}
else
{
return GetEmptyDesignTimeHtml();
}
}
Public Overrides Function GetDesignTimeHtml() As String
' Component is the instance of the component or control that
' this designer object is associated with. This property is
' inherited from System.ComponentModel.ComponentDesigner.
simpleControl = CType(Component, Simple)
If simpleControl.Text.Length > 0 Then
Dim sw As New StringWriter()
Dim tw As New HtmlTextWriter(sw)
Dim placeholderLink As New HyperLink()
' Put simpleControl.Text into the link's Text.
placeholderLink.Text = simpleControl.Text
placeholderLink.NavigateUrl = simpleControl.Text
placeholderLink.RenderControl(tw)
Return sw.ToString()
Else
Return GetEmptyDesignTimeHtml()
End If
End Function
備註
方法的預設行為 GetEmptyDesignTimeHtml 是傳回包含元件名稱的字串。 GetEmptyDesignTimeHtml當沒有設計階段 HTML 標籤時, GetDesignTimeHtml 應該在 方法的實作中呼叫 方法。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應