Hot answers tagged web-part-property
7
It is not safe to store credentials, connectionstrings or similar in web parts.
All users with contributor (designer in SP2010) settings and upward can export the web part and fetch the values from the .webpart/.dwp xml.
You can set the web part to not allow export, or not to export sensitive data (sensitive data is set on using the IsSensitive parameter ...
7
I hope this can help you, althought I have not tested it. You can find an example here: http://www.sharepoint-tips.com/2010/06/validating-web-part-properties.html
private string _webPartContentLink = null;
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("Services")]
...
4
You will need to add a ID to your ToolPart (EditorPart). For example:
public MyEditorPart(string webPartID)
{
this.ID = "MyEditorPart" + webPartID;
}
http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?List=70640fe5-28d9-464f-b1c9-91e07c8f7e47&ID=36
3
On load.
But that may not be a bad thing. You didn't provide many details about your requirements, so hard to say for sure. If the property depends on something that may change external to the web part, then you probably should leave it there so that only valid values are restored when the page is loaded.
However, if the validation only applies when the ...
3
As far as i remember setting properties requires Designer permissions in SP2010 (due to Fear of XSS). This might explain the behaviour you are seeing.
You may also need to switch:
[Microsoft.SharePoint.WebPartPages.WebPart.WebPartStorage(Storage.Personal)]
for the newer:
[System.Web.UI.WebControls.WebParts.Personalizable(PersonalizationScope.User)]
3
Abe you said:
I downloaded the source but it only
appears to work with the static drop
down list of items. I followed your
instructions but was never able to get
the drop down working with an internal
list. Is this possible to do by
following the instructions you have
provided? If so, would it be possible
to get you to post up the working ...
2
I have a custom ToolPart that reads from a database, but you could change it to read from a SPList instead
public class CustomToolPart : ToolPart {
protected override void CreateChildControls() {
ddlCustom = new DropDownList();
ddlCustom.ID = "ddlCustom";
ddlCustom.ToolTip = "Custom";
try {
using ...
2
This purely depends on where in the life cycle of the Web Part you use the properties.
If you use the values early before the "ToolPane" gets the clicked event for Apply/OK which causes your ToolParts ApplyChanges to fire and change the properties, well then the changes wont show up until next pageload.
If you use the values late (after the clicked event) ...
2
In addition to what Wictor said, remember to define your own ValidationGroup when you are using custom or out of the box ASP.NET validators, that way you dont get interference from other validation controls that might be on the same page when you do a post back (maybe a subject for your book Wictor?:-)
1
This article from Microsoft describes exactly how to use web part properties: http://msdn.microsoft.com/en-us/library/dd584174(v=office.11).aspx
Basically, you mark (decorate) a c# Property in your code as follow:
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("MyCategory")]
[WebDisplayName("Display ...
1
Christan,
There are no out-of-the-box editorparts that display multilines or anything that have been tailored to your specific needs. The correct way of doing this is to use a custom EditorPart/ToolPart.
Technically, you could probably hack something together with jQuery, but I'll leave to others to explain how to do that. In any case, it would be more ...
1
It happens on every load.
The WebPartManager creates your web part using the default constructor and then applies all the stored values of properties. There really isn't any other way it can do it. The only information it has is the Property and the value, only your code knows how/where if the value is assigned to members internally.
As Paul writes if you ...
1
Check out the following article: https://www.nothingbutsharepoint.com/sites/devwiki/articles/Pages/SharePoint-Web-Parts-with-jQuery-and-the-Web-ToolPart.aspx
Only top voted, non community-wiki answers of a minimum length are eligible