Sharepoint 2010 Sharepoint 2010自定义属性
我正在为Sharepoint 2010构建一个Web部件。我可以创建可通过Sharepoint用户界面编辑的自定义属性。没问题 问题是:我想使用一个自定义对象(Properties.cs)来定义那些相同的属性(并保持编辑功能可用),而不是像在internet上显示的那样转储Webpart.cs中的所有代码Sharepoint 2010 Sharepoint 2010自定义属性,sharepoint-2010,custom-properties,Sharepoint 2010,Custom Properties,我正在为Sharepoint 2010构建一个Web部件。我可以创建可通过Sharepoint用户界面编辑的自定义属性。没问题 问题是:我想使用一个自定义对象(Properties.cs)来定义那些相同的属性(并保持编辑功能可用),而不是像在internet上显示的那样转储Webpart.cs中的所有代码 有办法做到这一点吗?因为我不想在webpart类中抽取所有属性(可编辑或不可编辑)。是的,您可以这样做。。。通过使用继承和创建基类,如下所示 1-首先使用override CreateChil
有办法做到这一点吗?因为我不想在webpart类中抽取所有属性(可编辑或不可编辑)。是的,您可以这样做。。。通过使用继承和创建基类,如下所示 1-首先使用override CreateChildControls方法创建从WebPart类继承的基类,例如
<XmlRoot("MyWebPartBase")> _
<ToolboxItemAttribute(True)> _
Public Class BaseWebPart
Inherits WebPart
Protected Overrides Sub CreateChildControls()
Dim control As Object = Page.LoadControl(ascxPath)
If control IsNot Nothing Then
control.WebPartControl = Me
Controls.Add(CType(control, Control))
End If
End Sub
'Add public properties here
End Class
Public Class BaseUserControl
Inherits UserControl
Private _WebPartControl As BaseWebPart
Public Property WebPartControl As BaseWebPart
Get
Return _WebPartControl
End Get
Set(ByVal value As BaseWebPart)
_WebPartControl = value
End Set
End Property
Public ReadOnly Property WebPartID() As String
Get
Return WebPartControl.ID
End Get
End Property
End Class