Creating document libraries with Content Types

Now we are going to create an actual document library with the Proposal Content Type attached.

How to do it...

Open the SP2010ProposalLibrary Visual Studio Solution you created in the previous recipe:

  1. Right-click on the SP2010ProposalLibrary and select Add | New Item.
  2. Select List Definition From Content Type from the presented list, provide a name such as ProposalDocumentLibrary and click on the Add button.
  3. A dialog will come up. Enter Proposal Document Library in response to the question What is the display name of the list definition?. Choose Proposal in the drop-down in response to the question What content type would you like to use for your list definition?. Ensure the checkbox is enabled for Add a list instance for this list definition, and click on the Finish button.
  4. In the Elements.xml (with a ListTemplate node) file that opens, change the Description attribute to something such as List Definition for the Proposal Document Library.
  5. In the Proposal Document Library section of the Solution, right-click on ListInstance1 and rename this to ProposalListInstance. Expand this node to expose the Elements.xml file underneath.
  6. Edit the Elements.xml file (which will have a ListInstance node in it). Change the Title to Proposals. Change the URL to Lists/ProposalListInstance. Finally, change the Description to Document Library to manage Proposals.
  7. Your Solution Explorer should now looks as follows:
How to do it...

Now, let us deploy the Solution and observe the results:

  1. Right-click the SP2010ProposalLibrary project and select Deploy Solution. Wait until you see the Deploy Succeeded message in the bottom left-hand corner of Visual Studio.
  2. Select Site Actions | Site Settings. Click on Manage Site Features that appears under the Site Actions section. Note that the Proposal Library is there and is activated:
    How to do it...
  3. Note that a Proposals link has appeared in the quick launch (left-hand navigation) under the Libraries section:
    How to do it...
  4. Click on the Proposals link. On the Documents tab of the ribbon, click on the drop- down New Document - and note the specific option to create a new "Proposal":
    How to do it...
  5. Note the document that comes up starts with the defined template, and the "document information panel" shows the meta data for the document (the Site Columns that were defined with the Content Type).
    How to do it...
  6. Close/save the document and provide a name such as Proposal for XYZ Corp.

Congratulations! You have enhanced our Feature with Visual Studio 2010 SharePoint 2010 developer tools, created a list definition and list instance, deployed this to the sample site, and activated the Feature.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.203.172