Answered by:
Webpart property -> customizable (rich text)

Question
-
Hi all,
i want to develop a webpart that has some custom properties, but i don't want the default behavior of a string property...private string _message = string.empty;
I don't know if this is possible, but I whould like to give the user the possibility when they want to edit the webpart, they get a richtext environment (like the InputFormTextBox from Microsoft.Publishing)
[WebBrowsable(true)]
[Personalizable(PersonalizationScope.Shared)]
[WebDisplayName("Message")]
[Category("myCategory")]
public string Message
{get {
return _message;
}
}set {
}
_message = value;
Any idea's?
Greetz
Wednesday, November 12, 2008 12:00 PM
Answers
-
Thx for the quick reply, I've just found a blog on the net about the EditorPart
Creating custom editor parts for a SharePoint webpart
was also very helpful ;-)
- Marked as answer by Deyaert Thomas Wednesday, November 12, 2008 12:56 PM
- Marked as answer by Deyaert Thomas Wednesday, November 12, 2008 12:56 PM
- Marked as answer by Deyaert Thomas Wednesday, November 12, 2008 12:56 PM
Wednesday, November 12, 2008 12:55 PM
All replies
-
Hello,
you should skip the WebBrowsable attribute and instead make an EditorPart (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.editorpart.aspx) for your WebPart. With an EditorPart you have full control of the WebPart properties.
Good luck
/WW- Proposed as answer by Wictor Wilén [MVP]MVP Wednesday, November 12, 2008 12:56 PM
Wednesday, November 12, 2008 12:04 PM -
Thx for the quick reply, I've just found a blog on the net about the EditorPart
Creating custom editor parts for a SharePoint webpart
was also very helpful ;-)
- Marked as answer by Deyaert Thomas Wednesday, November 12, 2008 12:56 PM
- Marked as answer by Deyaert Thomas Wednesday, November 12, 2008 12:56 PM
- Marked as answer by Deyaert Thomas Wednesday, November 12, 2008 12:56 PM
Wednesday, November 12, 2008 12:55 PM -
Hi,
I would like to know about the differences between EditorPart and an ordinary webbrowsable property of webpart (ComponentModel.Category) . Could you please provide advantages of EditorPart with examples?
Tuesday, February 17, 2009 6:40 AM -
Hi,
check out these posts that I made about Web Part Properties:
http://www.wictorwilen.se/Post/Web-Part-Properties-part-1-introduction.aspx
http://www.wictorwilen.se/Post/Web-Part-Properties-part-2-Editor-Parts.aspx
/WW
http://www.wictorwilen.se/Tuesday, February 17, 2009 10:43 PM -
Thank you, Wictor for such a quick reply. I didn't expect such a quick reply. ( I think, you have subscribed for the email notification of the forum post. That feature is really adding value !!!)
From your articles, I got an idea about limitations of webpart webbrowsable properties which can be concluded as follows
First of all the properties we wanted to edit was located in their own category at the bottom, not that easy to find for inexperienced/untrained users.
Secondly this sample Web Part, has properties depending on each other (username is only required when using user time line and search text only when using search mode). Your own Web Parts may have more advanced dependencies or require that lists are filled during the editing.
I am focusing on the second point. I have the following problem.
There is a gridView in my sharepoint site. When user selects a row (click a hyperlink), the contents of the row must be displayed in the editorpart. User must be able to edit the values in the editorpart. This updated values will be reflected in gridview after clicking the "Apply" button.
I think the answer is somewhere near "WebPartManager.EditDisplayMode". I am a newbie in SharePoint and would appreciate if you can provide source code for the above mentioned scenario.
Thanks
Lijo
Wednesday, February 18, 2009 2:00 PM -
Hi,
if you want to sync values from your webpart to your editorpart, you have to set some properties on your webpart object which you then fetch in the editorpart SyncChanges method.
You could have your gridview row as a property of your webpart.
/WW
http://www.wictorwilen.se/Wednesday, February 18, 2009 11:32 PM -
I have a couple of questions regarding webpart.
How SharePoint application(which is partially trusted, WSS_Minimal) is able to use a web part that is in the GAC(even without adding “Allow Partially Trusted Callers”) ?
(Note: My assembly is in GAC, it is signed. Signed assemblies does not allow partially trusted callers, if it is not APTCA)Another question, why we use "Safe Control" ?
Any help?
Friday, March 27, 2009 12:11 PM