本文整理匯總了VB.NET中System.Web.UI.Design.ControlDesigner.ViewControl屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET ControlDesigner.ViewControl屬性的具體用法?VB.NET ControlDesigner.ViewControl怎麽用?VB.NET ControlDesigner.ViewControl使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Web.UI.Design.ControlDesigner
的用法示例。
在下文中一共展示了ControlDesigner.ViewControl屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: ToolboxData
' 導入命名空間
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports System.Web.UI.WebControls
Imports System.Reflection
Namespace ControlDesignerSamples.VB
' Derive a simple Web control from Label to render a text string.
' Associate this control with the SimpleTextControlDesigner.
<DesignerAttribute("ControlDesignerSamples.CS.SimpleTextControlDesigner"), _
ToolboxData("<{0}:MyLabelControl Runat=""Server""><{0}:MyLabelControl>")> _
Public Class MyLabelControl
Inherits Label
' Use the Label control implementation, but associate
' the derived class with the custom control designer.
End Class
' Mark the designer with the SupportsPreviewControlAttribute set
' to true. This means the base.UsePreviewControl returns true,
' and base.ViewControl returns a temporary preview copy of the control.
<SupportsPreviewControl(True)> _
Public Class SimpleTextControlDesigner
Inherits TextControlDesigner
' Override the base GetDesignTimeHtml method to display
' the design time text in italics.
Public Overrides Function GetDesignTimeHtml() As String
Dim html As String = String.Empty
Try
' Get the ViewControl for the associated control.
Dim ctrl As Label = CType(ViewControl, Label)
' Set the default text, if necessary
If ctrl.Text.Length = 0 Then
ctrl.Text = "Sample Text"
End If
' Set the style to italic
ctrl.Style.Add(HtmlTextWriterStyle.FontStyle, "italic")
' Let the base class create the HTML markup
html = MyBase.GetDesignTimeHtml()
Catch ex As Exception
If String.IsNullOrEmpty(html) Then
' Display the exception message
html = GetErrorDesignTimeHtml(ex)
End If
End Try
Return html
End Function
End Class
End Namespace