Tuesday, August 25, 2009

Create custom property in a web part as a dropdown list

SharePoint allows you to create custom web parts to help you provide highly customized solutions to your clients/users. The properties of these web parts are added by default but to further customize the solution, you can also create custom properties. The following example demonstrates how to add a custom dropdown property to a custom webpart.
// Create a Enum for Languages

public enum LanguageByEnum

{
English = 0,
French,
Spanish
};

// Create Get/Set for the dropdown property

protected LanguageByEnum languageName;

[Personalizable(PersonalizationScope.User),
Category("Select Language"),
WebBrowsable, WebDisplayName("Select language:")]
public LanguageByEnum SelectedLanguage
{
get { return languageName; }
set { languageName = value; }
}

I have written the same here also:Create custom property in a web part as a dropdown list

Samarendra Swain

No comments:

Post a Comment