How do I set a friendly name for SharePoint custom property enums? - sharepoint

I have a simple web part with a custom enum property (which SharePoint renders for me as a dropdown).
Is there a way to render friendly names for the enum values?
I have tried System.ComponentModel.DescriptionAttribute, but it does not seem to work. I also tried Microsoft.SharePoint.WebPartPages.FriendlyNameAttribute, but it cannot be applied to enum values.

I assume you're using the ToolPart; why not just wire up your own dropdown instead of letting sharepoint bind the enum for you?

Related

Umbraco add custom Document Type

Is it possible to add a custom control to the Document Type? Suppose i couldn't create a multiselect or just a simple textfield control. How could i create a custom one and use that from the Document Type page in Umbraco?
If this is possible, then what steps need to be taken? Because i can add all sorts of config information in the Document Type controls that currently exist in there. Like, when i add a textfield i can gvie it a name, an alias and a validation message (and it has some others options).
Do i have to build the custom Document Type control in a specific way? And how is it saved to the database? How does Umbraco handle that?
Any information on this matter is more than welcome!
Since adding custom document types is native to Umbraco, and judging by the description in your question, I'm going to assume that you are talking about adding custom data types with user controls.
If so, check some of the following links on the subject, it's actually fairly simple:
Creating custom datatypes using the umbraco usercontrol wrapper (I personally used this one)
Custom DataTypes in Umbraco
Creating a custom datatype using the usercontrol wrapper (Video tutorial)

How to display "ContentType" name in search results?

I have a MOSS site where I have created custom content types and activated those on a document library. Now I want to use a custom XSL stylesheet with search results to pull back those documents and display the name of the custom content type assigned for each one.
I know how to create managed properties and map those, etc... but can not seem to find the built-in type that would have the name I assigned to the custom content types? You would think this would be simple - but simply using a built-in one like "ContentType" returns something generic and not the name of the custom type.
Any ideas?
The default content type managed property is mapped to multiple crawled properties, with the first one usually being the mime type. I think there is a way to get all values of a property rather than just the first one in the search results xsl, but if that doesn't work out you can always add a custom managed property that only maps to the one crawled property.

Web Part with a custom property bound to a "choice" field from a content type?

I'm trying to make a custom property for a WebPart. The custom property should be a drop down with choices coming from a "choice" column from a content type. Is that even possible?
You have two options:
1) If your choices will never change then you can hardcode an enum with these values and use that as datatype for your custom property. SP will the automatically generate a drop down.
2) If you can't hardcode the values then you have to implement what is called an EditorPart where you can code the UI for handling entry of the custom property
You cannot data bind directly to a content type column as it does not exist as in a bindable form, only as an XML secification on the content type itself.
Better to specify the column as a lookup and databind to the list directly. However, that is not going to work well when you only want one lookup across multiple webs or site collections.
In that case create a list in a config site such as http://intranet/sites/config and code a lookup control to databind to that list. Then use the control in the webpart and in a custom field control on the content type.
A bit of work, but worth it if you require SharePoint edit control (versioning, security etc) access to the contents of the lookup and a single (changeable) source of data across the entire site.

What are the Valid values of the searchboxex AppQueryTerms enum?

I'm building a custom search page and attempting to use an existing custom search scope. I'm having success using the SearchBoxEx with the AppQueryTerms = "ContentType:'my custom content type name'" but when i try using AppQueryTerms = "Scope:'My Custom Search Scope'" I get no errors, but also no proper results. I know my scope is populated using the advanced search so I must be using AppQuwryTerms wrong.
I've searched the net over and can't find the list of allowed AppQueryTerms filters. Is this Enum know to the stackerverse?
The problem is your scope name has spaces.
This worked for me:
AppQueryTerms="Scope:"My Scope""
The values for SearchBoxEx.AppQueryTerms are not an enum. They're actually a query written in a specific language for SharePoint Searching. The syntax for SharePoint 2010 is defined by microsoft on this page. It follows the format <Property Name><Property Operator><Property Value>
Scope is your property name.
: is your property operator for
matching using the property store database.
My Scope is your
property value.
The page above states:
The property restriction must not include white space between the property name, property operator, and the property value, or the property restriction will be treated as a free-text query. The length of a property restriction is limited to 2,048 characters.
Therefore, as in HelloSharePoint's example, you have to wrap the property value in quotes if it includes spaces.
Does your custom scope appear in the web sites list of Scopes?
http://intranet/[sitecollection]/_layouts/viewscopes.aspx?mode=site
Does the scope appear in a Display Group?

Hiding a SharePoint Custom Field Type in Edit and Create mode

I am trying to create a Custom Field Type in SharePoint.
This control has it's value set based on another field in the same list.
Because of this requirement, this field should be displayed only in the Display Mode, and not in the Edit or Create mode.
How do I ensure this?
If I just code the ASCX control to not render a field, the field will show up like this in the Edit and Create mode.
alt text http://www.mannsoftware.com/blog/Lists/Photos/121308_0204_CrossSiteLo6.png
Generally you set the SPField.ReadOnlyField property to True to achieve the desired behaviour for any field. (Don't forget to SPField.Update accordingly!) There is an equivalent CAML attribute for list definitions, I believe.
That said, in your control class deriving from BaseFieldControl, you might just override the RenderFieldForInput() method and not call the base implementation to ensure nothing is rendered during Create or Edit. However, this would still render the field's table row in the form, which is probably not what you want. So to enforce the desired behaviour, use ReadOnlyField and override Update() in your SPField (not field control) class to always have it set to True.
It might be easier to just change this on a list-by-list basis by going to the Advanced section of the List Settings, setting Allow management of content types? to Yes, and then editing your content type to change the value of your field to 'hidden'.
Take a look at this blog post. I think it will give you some ideas. The concept uses different rendering templates based on the mode.
http://sharepoint.nailhead.net/2008/04/creating-rendering-template-that.html
Did you try and set the field as hidden?
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.hidden.aspx
Custom FORMS pages for new item and edit item (NewForm.aspx and EditForm.aspx) would be another way to achieve this.
Setting the ShowInEditForm and ShowInNewForm properties solved this for me.

Resources