SharePoint Events

  5/13/2013 - Conference: SharePoint Summit 2013
  5/21/2013 - Webcast: SharePoint 2013 and ECM: Content Migration and Storage
  5/22/2013 - Webcast: Managing CAD in SharePoint
  5/23/2013 - Webcast: SharePoint Document Automation and E-Forms for Financial Services
  5/24/2013 - Webcast: What's New in Search for SharePoint 2013

 SharePoint Videos

  Why SharePoint 2013
  SharePoint 2013 Launch
  SharePoint 2013 Migration and Governance
  SharePoint 2013 and Enterprise Content Management
  Top Benefits of SharePoint 2013
  What's New in Business Intelligence in Office and SharePoint 2013
  SharePoint and Office 2013 Integration
  SharePoint 2013 Infrastructure Preview
  SharePoint, Lync, and, Exchange in the Cloud with Office 365
  Advanced Reporting in SharePoint with Microsoft Power View

 Archives

Opening SharePoint Links in a new windowUse SHIFT+ENTER to open the menu (new window).
Mail Enabled Lists vs. The Missing Windows 2008 POP3/IMAP Server Use SHIFT+ENTER to open the menu (new window).
7 Tools for SharePoint DevelopersUse SHIFT+ENTER to open the menu (new window).
Public Facing Masterpage TechniquesUse SHIFT+ENTER to open the menu (new window).
How to Quickly Deploy and Activate a Timer Service to Your Site CollectionUse SHIFT+ENTER to open the menu (new window).
Custom SharePoint Master Page Feature with WSP BuilderUse SHIFT+ENTER to open the menu (new window).
Date Math with InfoPathUse SHIFT+ENTER to open the menu (new window).
Enterprise Search Tricks and Tips Part 1Use SHIFT+ENTER to open the menu (new window).
Populating Word Documents With SharePoint Data. Try The DIP!Use SHIFT+ENTER to open the menu (new window).
Programmatic Deep Dive into Blank SharePoint Lookup ColumnsUse SHIFT+ENTER to open the menu (new window).
1 - 10 Next
Creating a Web Part with Custom Properties

By: Kathryn Bartlett

Create a Visual Web Part project in Visual Studio.  In the file VisualWebPart1.cs, add your custom properties:

SharePoint_Blog_Creating_a_Web_Part_with_Custom_Properties

The Personalizable attribute is what tells is the Web Part framework to store this property in the database.  The WebBrowsable attribute is what tells the Web Part framework to make this property visible in the Edit Web Part properties pane.  The WebDisplayName attribute changes the display name visible within the Edit Web Part properties pane.  In this case, if we did not alter the display name, it would appear as CustomProperty.  Since we have now altered the display name to include a space, these two words will not run together.  The Category attribute will change what section of the Edit Web Part properties pane this setting will appear in.  If not specified, the custom property will appear in a Miscellaneous section. 

In the file VisualWebPart1UserControl.ascx.cs, add a property to store our custom web part.

SharePoint_Blog_Creating_a_Web_Part_with_Custom_Properties

Now, back in the VisualWebPart1.cs file, alter the CreateChildControls() method to pass this web part into our user control.

SharePoint_Blog_Creating_a_Web_Part_with_Custom_Properties

Now, in the VisualWebPart1UserControl.ascx.cs file, update the code to display the value entered for our custom property in a label we have added to our VisualWebPart1UserControl.ascx file.

SharePoint_Blog_Creating_a_Web_Part_with_Custom_Properties

Now deploy your web part and add it to your page.  When we go to edit our web part, we see there is a section called Custom Settings which contains our property.

SharePoint_Blog_Creating_a_Web_Part_with_Custom_Properties

Upon entering text into this field, hitting OK, and saving the page, we will now see our text appear in the label for our web part.

SharePoint_Blog_Creating_a_Web_Part_with_Custom_Properties

By: Kathryn Bartlett

        

Comments

There are no comments yet for this post.
Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Your Name *


e-mail address *


Website (optional)


Comment *


Attachments

 Subscribe

  GigWerks RSS  Gig Werks Mailing List 

 Contact Us

 Connect

 Resources

  On Demand SharePoint Webcast Recordings
  Upcoming Webinars
  SharePoint Resources
  Business Intelligence Resources
  Gig Werks Website



©2009 Gig Werks. All rights reserved. Privacy Policy