I have created a custom WebPart that has some configuration properties. The values for these properties are a Site URL and list name. I want to show a drop down list with all site names and lists for the selected sites. How can I get to show a custom editor component for a property in SharePoint? I don't want to get the default text editor.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You will want to create a custom ToolPart. Here is a guide: http://sharepoint-insight.blogspot.com/2008/10/sharepoint-creating-web-part-with.html
Basically in your WebPart code you will need to override the GetToolParts function and return a
ToolPart[]
Change your toolpart constructor to accept an
SPWeb
object (pass it theSPContext.Current.Web
object from your Web Part). To get the list of lists, in your toolpart you will need to create a dropdownlist inside yourCreateChildControls()
method. Using the SPWeb object you got from the Constructor you can use a for each to get all the lists for the current site.So in your web part do this:
Add a class like this:
The above code assumes the name of your WebPart is MyWebPart and that there is a TargetListGUID property. To add a site selection you can do pretty much the same thing in the toolpart (add another dropdownlist). If you use the SelectionChanged event on it you can use it to populate the lists dropdown.