Web Part Property Snippet

Snippets are a great features in VS 2005.  I like using them for getting out codes rather quickly, and having some standard for everyone.  I thought it might be useful for everyone to have.  I do like the shortcut in VS 2005, with typing in "wpp" and generating the web part property.  There are so many web part properties that need to be generated, I like this as a quick way to get them developed.

<CodeSnippets
    xmlns="
http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>SharePoint Web Part Property</Title>
      <Description>Create a SharePoint Web Part Property, Field and Default Field</Description>
      <Author>Morgan Everett, 4 QTRS LLC</Author>
      <Shortcut>wpp</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Replace with the tyoe of the Web Part Property</ToolTip>
          <Default>string</Default>
        </Literal>
        <Literal>
          <ID>PropertyName</ID>
          <ToolTip>Replace with the Name of the Web Part Property</ToolTip>
          <Default>MyWebPartProperty</Default>
        </Literal>
        <Literal>
          <ID>Category</ID>
          <ToolTip>Replace with the name of the Category where this property will appear in the ToolPane</ToolTip>
          <Default>MyCategory</Default>
        </Literal>
        <Literal>
          <ID>MyFriendlyName</ID>
          <ToolTip>Replace with the Friendly Name of the Web Part Property</ToolTip>
          <Default>MyFriendlyName</Default>
        </Literal>
        <Literal>
          <ID>MyDescription</ID>
          <ToolTip>Replace with the Description of the Web Part Property</ToolTip>
          <Default>MyDescription</Default>
        </Literal>
      </Declarations>

      <Code Language="CSharp">
        <![CDATA[
        protected const $type$ default$PropertyName$ = "MyDefault";
        protected $type$ m_$PropertyName$ = default$PropertyName$;
      

        [Browsable(true),
        Category("$Category$"),
        DefaultValue(default$PropertyName$),
        WebPartStorage(Storage.Shared),
        FriendlyName("$MyFriendlyName$"),
        Description("$MyDescription$")]
        public $type$ $PropertyName$
        {
            get
            {
                return this.m_$PropertyName$;
            }

            set
            {
                this.m_$PropertyName$ = value;
            }
        }]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

Installing

You will need to take this snippet and save it as an xml file, and then install it into My Documents\Visual Studio 2005\Project\Code Snippets, and it should be available in your application as soon as you place the XML.

Morgan

Sharing about SharePoint

Ok, so Mark and I have decided to share what we have been learning about SharePoint. We have been hammering away at SharePoint signifcantly, for the last 6 months and even though the product is 3 years old, there seems to be so little people know about it. 

We are having to dig through blog after blog, and document after document to gleam the valuable information we need.  We have really drank the koolaid, and we are using Office and SharePoint as an "Application Platform".

I know Microsoft has been starting to push this recently, and we have really bought in and pushing it very hard to try and see how far we can stretch and pull SharePoint into doing what we need to.  While the next version, seems to solve so many headaches, we are still having to find workarounds or create components that we need to fit into an application today.  We are going to share some of our experiences with everyone, and hopeful make the SharePoint world a little clearer.

At least, that is what we will attempt..

Morgan