Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages
' A simple Web Part with a single custom Text property.
<DefaultProperty("Text"), ToolboxData("<{0}:WebPart1
runat=server></{0}:WebPart1>"),
XmlRoot(Namespace:="WebPartLibrary1")> _
Public Class WebPart1
Inherits Microsoft.SharePoint.WebPartPages.WebPart
Private Const _defaultText As String = ""
Dim _text As String = _defaultText
' The Web Part's single custom Text property.
<Browsable(True), Category("Miscellaneous"),
DefaultValue(_defaultText), WebPartStorage(Storage.Personal),
FriendlyName("Text"), Description("Text Property")> _
Property [Text]() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
' An overridden version of the GetToolParts() method of the WebPart base class.
' The WebPartToolPart automatically displays the Web Part's standard properties
' The CustomPropertyToolPart displays automatically displays
' the Web Part's custom properties
Public Overrides Function GetToolParts() As ToolPart()
Dim toolParts(2) As ToolPart
Dim custom As CustomPropertyToolPart = New CustomPropertyToolPart
custom.Expand("Miscellaneous")
Dim wptp As WebPartToolPart = New WebPartToolPart
With wptp
.Expand(WebPartToolPart.Categories.Appearance)
.Hide(WebPartToolPart.Properties.FrameState)
.Hide(WebPartToolPart.Properties.FrameType)
End With
toolParts(0) = custom
toolParts(1) = wptp
Return toolParts
End Function
' Renders the Web Part.
Protected Overrides Sub RenderWebPart(ByVal output
As System.Web.UI.HtmlTextWriter)
output.Write(SPEncode.HtmlEncode([Text]))
End Sub
End Class