<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DevExpertise &#187; SharePoint UI</title>
	<atom:link href="http://www.devexpertise.com/category/sharepoint/sharepoint-ui/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devexpertise.com</link>
	<description>Practical tips and tricks for all things .NET, SharePoint, Silverlight, InfoPath, and general application development.</description>
	<lastBuildDate>Wed, 12 May 2010 14:32:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ten Free SharePoint Themes</title>
		<link>http://www.devexpertise.com/2009/03/20/ten-free-sharepoint-themes/</link>
		<comments>http://www.devexpertise.com/2009/03/20/ten-free-sharepoint-themes/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 12:59:11 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint UI]]></category>
		<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/2009/03/20/ten-free-sharepoint-themes/</guid>
		<description><![CDATA[The Ten Themes for SharePoint in VSeWSS was just released and contains 10 very cool themes, absolutely free and full of glitzy eye candy.&#160; I personally don’t use VSeWSS, but you can just extract the contents of the MSI file and pull out the THEMES and LAYOUTS folders within the Visual Studio solutions, and use [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=0a87658f-20b8-4dcc-ad7a-09ad22641f3a" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.microsoft.com');">Ten Themes for SharePoint in VSeWSS</a> was just released and contains 10 very cool themes, absolutely free and full of glitzy eye candy.&#160; I personally don’t use VSeWSS, but you can just extract the contents of the MSI file and pull out the THEMES and LAYOUTS folders within the Visual Studio solutions, and use that for a custom theme.&#160; </p>
<p>For tips and tricks on how to properly deploy themes to your SharePoint environment, take a look at my previous post <a href="http://www.devexpertise.com/2009/02/11/installing-a-theme-as-a-sharepoint-feature/" >here</a>, and you may also be interested in the Vista theme I put together that I describe <a href="http://www.devexpertise.com/2009/02/09/creating-a-custom-vista-theme-for-sharepoint/" >here</a>.</p>
<p>Here are screenshots of the ten free themes:</p>
<p><strong><em>Construction:</em></strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/construction-preview.jpg"  rel="lightbox"><img title="Construction_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="628" alt="Construction_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/construction-preview-thumb.jpg" width="720" border="0" /></a><strong><em>        <br /></em></strong></p>
<p><strong><em>Contoso</em>:</strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/contoso-preview.jpg"  rel="lightbox"><img title="Contoso_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="464" alt="Contoso_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/contoso-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>Corporate</em>:</strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/corporate-preview.jpg"  rel="lightbox"><img title="Corporate_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="541" alt="Corporate_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/corporate-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>Events</em>:</strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/events-preview.jpg"  rel="lightbox"><img title="Events_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="613" alt="Events_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/events-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>OARP</em></strong>:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/oarp-preview.jpg"  rel="lightbox"><img title="OARP_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="608" alt="OARP_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/oarp-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>Procurement:</em></strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/procurement-preview.jpg"  rel="lightbox"><img title="Procurement_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="621" alt="Procurement_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/procurement-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>Publishing:</em></strong>&#160;</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/publishing-preview.jpg"  rel="lightbox"><img title="Publishing_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="608" alt="Publishing_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/publishing-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>Sporting:</em></strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/sporting-preview.jpg"  rel="lightbox"><img title="sporting_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="623" alt="sporting_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/sporting-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>Startup:</em></strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/startup-preview.jpg"  rel="lightbox"><img title="Start-Up_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="608" alt="Start-Up_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/startup-preview-thumb.jpg" width="720" border="0" /></a></p>
<p><strong><em>Team:</em></strong></p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/team-preview.jpg"  rel="lightbox"><img title="Team_Preview" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="588" alt="Team_Preview" src="http://www.devexpertise.com/wp-content/uploads/2009/03/team-preview-thumb.jpg" width="720" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/03/20/ten-free-sharepoint-themes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating a Custom ASP.NET Application into SharePoint (Part 3)</title>
		<link>http://www.devexpertise.com/2009/03/04/integrating-a-custom-aspnet-application-into-sharepoint-part-3/</link>
		<comments>http://www.devexpertise.com/2009/03/04/integrating-a-custom-aspnet-application-into-sharepoint-part-3/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 01:58:16 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Object Model]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint UI]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Features]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/2009/03/04/integrating-a-custom-aspnet-application-into-sharepoint-part-3/</guid>
		<description><![CDATA[In my last two posts here and here I began describing how to integrate a custom ASP.NET application into SharePoint.&#160; The first post focused on the essentials, and detailed how to get your application into the SharePoint LAYOUTS folder structure, specifically where to place your files and how to inherit SharePoint’s look and feel by [...]]]></description>
			<content:encoded><![CDATA[<p>In my last two posts <a href="http://www.devexpertise.com/2009/02/18/integrating-a-custom-aspnet-application-into-sharepoint-part-1/" >here</a> and <a href="http://www.devexpertise.com/2009/02/25/integrating-a-custom-aspnet-application-into-sharepoint-part-2/" >here</a> I began describing how to integrate a custom ASP.NET application into SharePoint.&#160; The first post focused on the essentials, and detailed how to get your application into the SharePoint LAYOUTS folder structure, specifically where to place your files and how to inherit SharePoint’s look and feel by using its master page.&#160; The second post focused on configuring permissions for your application and also demonstrated a few handy built-in controls that you can leverage to give your application that true SharePoint-like integrated look and feel.</p>
<p>This post will explain how to add custom navigation for your application.&#160; There are a few different approaches that I like to take depending on the application, and I’ll demonstrate a couple of them for you.&#160; These can be used in any combination in order to achieve the navigation you’re aiming for.&#160; In fact, I <em>recommend</em> a combination of these to achieve a fully integrated navigation structure.</p>
<p><strong>Approach #1: Quick Launch Navigation      <br /></strong>Now, modifying the Quick Launch navigation menu is a trivial task.&#160; Simply go to Site Actions &gt; Site Settings and find the settings to modify the navigation (Quick Launch on team sites, and Navigation on publishing sites), and add and remove nodes to your heart’s content.&#160; While this manual method works just fine, it’s just that: manual.&#160; I always have the mindset of if I’m already deploying an application somewhere, I might as well automate as much of the setup steps as I can.&#160; Luckily through the use of features we are able to accomplish this easily.</p>
<p>For the sake of brevity, I am going to assume you know what a SharePoint feature is, what a solution package is, and how to create and deploy them.&#160; If not, there are plenty of great resources out there that will help you out.&#160; Anyways, the first step is to create the feature and associated feature receiver that will execute when the feature is activated on the site.&#160; The feature receiver is going to utilized the SharePoint Object Model to create navigation items.</p>
<p>The first step is to create the feature receiver, which must inherit from the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfeaturereceiver.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">SPFeatureReceiver</a> class and must implement the standard 4 feature operations: FeatureActivated, FeatureDeactivated, FeatureInstalled, and FeatureUninstalled.&#160; For this post I’m only adding the items in the FeatureActivated event, but it’s probably a good idea to clean these up in the FeatureDeactivated event in case the feature is ever deactivated.&#160; My feature receiver looks like this:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">namespace </span>DevExpertise.LayoutsApp {
    <span style="color: blue">public class </span><span style="color: #2b91af">FeatureReceiver</span>: <span style="color: #2b91af">SPFeatureReceiver </span>{
        <span style="color: blue">public override void </span>FeatureActivated(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
            <span style="color: blue">using </span>(<span style="color: #2b91af">SPWeb </span>site = (properties.Feature.Parent <span style="color: blue">as </span><span style="color: #2b91af">SPWeb</span>)) {
                <span style="color: green">// create the nodes
                </span><span style="color: #2b91af">SPNavigationNode </span>widgetManagementNode = <span style="color: blue">new </span><span style="color: #2b91af">SPNavigationNode</span>(<span style="color: #a31515">&quot;Widget Management&quot;</span>,
                    <span style="color: #2b91af">SPUrlUtility</span>.CombineUrl(site.Url, <span style="color: #a31515">&quot;DevExpertise.LayoutsApp/WidgetMgmt.aspx&quot;</span>), <span style="color: blue">true</span>);
                <span style="color: #2b91af">SPNavigationNode </span>viewWidgetsNode = <span style="color: blue">new </span><span style="color: #2b91af">SPNavigationNode</span>(<span style="color: #a31515">&quot;View Widgets&quot;</span>,
                    <span style="color: #2b91af">SPUrlUtility</span>.CombineUrl(site.Url, <span style="color: #a31515">&quot;DevExpertise.LayoutsApp/WidgetList.aspx&quot;</span>), <span style="color: blue">true</span>);
                <span style="color: #2b91af">SPNavigationNode </span>addWidgetNode = <span style="color: blue">new </span><span style="color: #2b91af">SPNavigationNode</span>(<span style="color: #a31515">&quot;Add Widget&quot;</span>,
                    <span style="color: #2b91af">SPUrlUtility</span>.CombineUrl(site.Url, <span style="color: #a31515">&quot;DevExpertise.LayoutsApp/AddWidget.aspx&quot;</span>), <span style="color: blue">true</span>);
                <span style="color: #2b91af">SPNavigationNode </span>widgetSettingsNode = <span style="color: blue">new </span><span style="color: #2b91af">SPNavigationNode</span>(<span style="color: #a31515">&quot;Modify Widget Settings&quot;</span>,
                    <span style="color: #2b91af">SPUrlUtility</span>.CombineUrl(site.Url, <span style="color: #a31515">&quot;DevExpertise.LayoutsApp/WidgetSettings.aspx&quot;</span>), <span style="color: blue">true</span>);

                <span style="color: green">// add the Widget management node to the menu (must be done first)
                </span>site.Navigation.QuickLaunch.AddAsLast(widgetManagementNode);

                <span style="color: green">// add the sub-items to the Widget Management node
                </span>widgetManagementNode.Children.AddAsLast(viewWidgetsNode);
                widgetManagementNode.Children.AddAsLast(addWidgetNode);
                widgetManagementNode.Children.AddAsLast(widgetSettingsNode);

                <span style="color: green">// update the site
                </span>site.Update();
            }
        }

        <span style="color: blue">public override void </span>FeatureDeactivating(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
            <span style="color: green">// do nothing
        </span>}

        <span style="color: blue">public override void </span>FeatureInstalled(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
            <span style="color: green">// do nothing
        </span>}

        <span style="color: blue">public override void </span>FeatureUninstalling(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
            <span style="color: green">// do nothing
        </span>}
    }
}</pre>
</div>
<p>
  <br />As you can see, it’s not complicated at all.&#160; Simply add as many <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.navigation.spnavigationnode.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">SPNavigationNodes</a> as you like!&#160; The next step is to tell the feature to execute the custom feature receiver.&#160; For that just add the ReceiverAssembly and ReceiverClass elements to your feature definition file:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot; <span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot;<span style="color: blue">?&gt;
&lt;</span><span style="color: #a31515">Feature
  </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">5856617E-BED2-4705-B030-735F7483225E</span>&quot;
  <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise Layouts Application</span>&quot;
  <span style="color: red">Description</span><span style="color: blue">=</span>&quot;<span style="color: blue">Contains the necessary components for the DevExpertise custom LAYOUTS application.</span>&quot;
  <span style="color: red">Version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0.0.0</span>&quot;
  <span style="color: red">Scope</span><span style="color: blue">=</span>&quot;<span style="color: blue">Web</span>&quot;
  <span style="color: red">Hidden</span><span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;
  <span style="color: red">ImageUrl</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise\devexpertiseLogo.png</span>&quot;
  <span style="color: red">ReceiverAssembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise.LayoutsApp, Version=1.0.0.0, culture=neutral, PublicKeyToken=d39eedb6cff9b1c8</span>&quot;
  <span style="color: red">ReceiverClass</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise.LayoutsApp.FeatureReceiver</span>&quot;
  <span style="color: red">xmlns</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>&quot;<span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">Feature</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />Once the feature is properly installed, it will show up under Site Features (note that this is scoped at the site level, and will need to be activated on each site):</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/image.png"  rel="lightbox"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="66" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/03/image-thumb.png" width="719" border="0" /></a> </p>
<p>
  <br />Cross your fingers, activate it, and you should the new navigation items:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/image1.png"  rel="lightbox"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="347" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/03/image-thumb1.png" width="143" border="0" /></a></p>
<p>
  <br />Not too shabby for a few lines of code, huh?&#160; You’re just as able to add items to the top navigation if you so desire too.&#160; </p>
<p>
  <br /><strong>Approach #2: Custom Actions<br />
    <br /></strong>One of my favorite things about SharePoint is the ability to extend just about anything, making it a true application development.&#160; Menu items are no exception, and they’re painfully simple to implement.&#160; You are able to add a custom link to the Site Actions menu, Site Settings menus, list menus, individual item menus, Central Administration menus, etc.&#160; If SharePoint has a menu somewhere, chances are you’re able to add your own item to it.&#160; There are 2 ways to do this and I’ll only be demonstrating it one way.&#160; In a future blog post I’ll show how to do all this stuff programmatically for an even more robust navigation structure.</p>
<p>For this sample Widgets application, I would like to take the navigation a bit further and add an item to the Site Actions menu and also create a group in Site Settings that will allow me to manage my application.&#160; To accomplish this, I added a new element manifest to my feature called CustomActions.xml, which will define our custom actions.&#160; Per MSDN, custom action files are included as part of a feature and deployed as XML element descriptions, and structured with a <a href="http://msdn.microsoft.com/en-us/library/ms460194.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">CustomAction</a> element, which serves as the core definition for a single action of a link or toolbar item. The following is my CustomActions.xml file, which defines a single action for the Site Actions menu:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot; <span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot; <span style="color: blue">?&gt;
&lt;</span><span style="color: #a31515">Elements </span><span style="color: red">xmlns</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>&quot;<span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">CustomAction
    </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">ManageWidgetAction</span>&quot;
    <span style="color: red">GroupId</span><span style="color: blue">=</span>&quot;<span style="color: blue">SiteActions</span>&quot;
    <span style="color: red">Location</span><span style="color: blue">=</span>&quot;<span style="color: blue">Microsoft.SharePoint.StandardMenu</span>&quot;
    <span style="color: red">Sequence</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot;
    <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">Manage Widgets</span>&quot;
    <span style="color: red">Description</span><span style="color: blue">=</span>&quot;<span style="color: blue">Manage your company's widget catalog.</span>&quot;
    <span style="color: red">ImageUrl </span><span style="color: blue">=</span>&quot;<span style="color: blue">/_layouts/images/actionssettings.gif</span>&quot;
    <span style="color: red">Rights</span><span style="color: blue">=</span>&quot;<span style="color: blue">ManageWeb,ManageLists</span>&quot;<span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">UrlAction </span><span style="color: red">Url</span><span style="color: blue">=</span>&quot;<span style="color: blue">~site/_layouts/DevExpertise.LayoutsApp/ManageWidgets.aspx</span>&quot; <span style="color: blue">/&gt;
  &lt;/</span><span style="color: #a31515">CustomAction</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">Elements</span><span style="color: blue">&gt;
</span></pre>
</div>
<p>
  <br />Let’s break this down a little bit:</p>
<ul>
<li><strong>Id</strong>.&#160; The ID of your custom action. </li>
<li><strong>GroupId</strong>. A pre-defined or custom that determines what group it will be placed into.&#160; A comprehensive list of built-in values can be found <a href="http://msdn.microsoft.com/en-us/library/bb802730.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">here</a>. </li>
<li><strong>Location</strong>.&#160; The location at which your custom action will be applied.&#160; A comprehensive list of built-in values can be found <a href="http://msdn.microsoft.com/en-us/library/bb802730.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">here</a>. </li>
<li><strong>Sequence</strong>.&#160; The order in which your custom action will appear in relation to other custom actions. </li>
<li><strong>Title</strong>.&#160; The display title of the action. </li>
<li><strong>Description</strong>.&#160; The description of the action, if applicable. </li>
<li><strong>ImageUrl</strong>. The image that is displayed next to the action, if applicable. </li>
<li><strong>Rights</strong>.&#160; A comma delimited list of <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">SPBasePermission</a> enumeration items.&#160; A comprehensive list of values can be found <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">here</a>. </li>
<li><strong>RequireSiteAdministrator</strong>.&#160; A true/false value indicating if this option is only visible to the site collection administrator. </li>
<li>UrlAction: This element defines where the link will take you.&#160; Be sure to specify either the ~site or ~sitecollection token which tells SharePoint to build the URL relative to either the site or site collection, respectively. </li>
</ul>
<p>Simply modify the feature to include this element manifest, redeploy it, reactivate it, and you should see the following in your Site Actions menu:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/image2.png"  rel="lightbox"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="200" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/03/image-thumb2.png" width="253" border="0" /></a></p>
<p>
  <br />Easy, huh?&#160; Let’s take this a step further and add a few items to the Site Setting page.&#160; You can either add items to existing groups on that page, or create your own.&#160; I created my own by specifying CustomActionGroup in my CustomActions.xml file, as well as a few CustomAction elements that will be a part of my custom group.&#160; The XML is fairly straightforward:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">CustomActionGroup
  </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">LayoutsAppCustomActionGroup</span>&quot;
  <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">Widget Application Settings</span>&quot;
  <span style="color: red">Sequence</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot;
  <span style="color: red">Location</span><span style="color: blue">=</span>&quot;<span style="color: blue">Microsoft.SharePoint.SiteSettings</span>&quot;<span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">CustomActionGroup</span><span style="color: blue">&gt;

&lt;</span><span style="color: #a31515">CustomAction
  </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">UserGroupAdminLinkForSettings</span>&quot;
  <span style="color: red">GroupId</span><span style="color: blue">=</span>&quot;<span style="color: blue">LayoutsAppCustomActionGroup</span>&quot;
  <span style="color: red">Location</span><span style="color: blue">=</span>&quot;<span style="color: blue">Microsoft.SharePoint.SiteSettings</span>&quot;
  <span style="color: red">Rights</span><span style="color: blue">=</span>&quot;<span style="color: blue">ManageWeb,ManageLists</span>&quot;
  <span style="color: red">Sequence</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot;
  <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">Manage Widget Categories</span>&quot;<span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">UrlAction </span><span style="color: red">Url</span><span style="color: blue">=</span>&quot;<span style="color: blue">~site/_layouts/DevExpertise.LayoutsApp/Categories.aspx</span>&quot; <span style="color: blue">/&gt;
&lt;/</span><span style="color: #a31515">CustomAction</span><span style="color: blue">&gt;

&lt;</span><span style="color: #a31515">CustomAction
  </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">UserGroupAdminLinkForSettings</span>&quot;
  <span style="color: red">GroupId</span><span style="color: blue">=</span>&quot;<span style="color: blue">LayoutsAppCustomActionGroup</span>&quot;
  <span style="color: red">Location</span><span style="color: blue">=</span>&quot;<span style="color: blue">Microsoft.SharePoint.SiteSettings</span>&quot;
  <span style="color: red">RequireSiteAdministrator</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
  <span style="color: red">Sequence</span><span style="color: blue">=</span>&quot;<span style="color: blue">2</span>&quot;
  <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">Modify Widget Permissions</span>&quot;<span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">UrlAction </span><span style="color: red">Url</span><span style="color: blue">=</span>&quot;<span style="color: blue">~site/_layouts/DevExpertise.LayoutsApp/Permissions.aspx</span>&quot; <span style="color: blue">/&gt;
&lt;/</span><span style="color: #a31515">CustomAction</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />The only notable thing to point out here is for the CustomAction elements, the GroupId is that of the CustomActionGroup I specified first.&#160; This tells SharePoint to put these actions in the custom group.&#160; Redeploy and reactivate your feature, and you will now have this in your Site Settings page:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/image3.png"  rel="lightbox"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="424" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/03/image-thumb3.png" width="838" border="0" /></a> </p>
<p>
  <br />Hopefully you can see from this post that it’s pretty easy to build navigation for your custom application and have that created when your application is deployed via a custom feature.&#160; In the next and final post in this series, I will show my approach to packaging everything up into features and solution packages, and how to deploy that to SharePoint in a simple and streamlined fashion.&#160; Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/03/04/integrating-a-custom-aspnet-application-into-sharepoint-part-3/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Integrating a Custom ASP.NET Application into SharePoint (Part 2)</title>
		<link>http://www.devexpertise.com/2009/02/25/integrating-a-custom-aspnet-application-into-sharepoint-part-2/</link>
		<comments>http://www.devexpertise.com/2009/02/25/integrating-a-custom-aspnet-application-into-sharepoint-part-2/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 03:18:55 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Object Model]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint UI]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/2009/02/25/integrating-a-custom-aspnet-application-into-sharepoint-part-2/</guid>
		<description><![CDATA[In my last post, I began describing how to integrate a custom ASP.NET application into SharePoint.&#160; SharePoint is a fantastic platform for building applications, and being able to create your own pages and application structure is a huge win when you need to add missing functionality, or to integrate a non-SharePoint application into SharePoint. 
My [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post, I began describing how to integrate a custom ASP.NET application into SharePoint.&#160; SharePoint is a fantastic platform for building applications, and being able to create your own pages and application structure is a huge win when you need to add missing functionality, or to integrate a non-SharePoint application into SharePoint. </p>
<p>My previous post covered the basics – where to place your custom artifacts, how to inherit the master page and navigation, and how the custom application runs in the context specified in the URL.&#160; This post will briefly cover securing your application pages and will also cover some useful design and UI techniques to give your application a truly integrated look and feel.</p>
<p>If you took at a look at the code I provided, you may have noticed that my custom base class that sets the master page is inheriting from LayoutsPageBase.&#160; This is a page in the object model that is specifically meant to be inherited, and provides us the means to check the users’ rights.&#160; Since <a href="http://community.bamboosolutions.com/members/Nat/default.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/community.bamboosolutions.com');" target="_blank">Natnael Gebremariam</a> of Bamboo Solutions already did a fantastic job of explaining this and some of the nuances <a href="http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2008/10/15/secure-a-sharepoint-application-page.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/community.bamboosolutions.com');" target="_blank">in his post here</a>, I will skip that and just provide a high-level overview.&#160; Basically there are 3 properties that can be overridden to customize the required permissions for your page:</p>
<ul>
<li><strong>AllowAnonymousAccess</strong>: A boolean value indicating if the page is accessible by anonymous users. </li>
<li><strong>RequireSiteAdministrator</strong>: A boolean value indicating if the page is <em>only </em>accessible by site collection administrators. </li>
<li><strong>RightsRequired</strong>: A list of <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">SPBasePermissions</a> that specify the granular permissions that are necessary to access the page. </li>
</ul>
<p>For the purposes of this blog series I kept it simple, and I’m denying anonymous access, not requiring users to be site collection administrators, but requiring the user to have at least ManageLists and ManageWeb permissions:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">protected override bool </span>AllowAnonymousAccess {
    <span style="color: blue">get </span>{
        <span style="color: blue">return false</span>;
    }
}

<span style="color: blue">protected override bool </span>RequireSiteAdministrator {
    <span style="color: blue">get </span>{
        <span style="color: green">// only allow site collection administrators access?
        </span><span style="color: blue">return false</span>;
    }
}

<span style="color: blue">protected override </span><span style="color: #2b91af">SPBasePermissions </span>RightsRequired {
    <span style="color: blue">get </span>{
        <span style="color: #2b91af">SPBasePermissions </span>permissions = <span style="color: blue">base</span>.RightsRequired
            | <span style="color: #2b91af">SPBasePermissions</span>.ManageLists
            | <span style="color: #2b91af">SPBasePermissions</span>.ManageWeb;

        <span style="color: blue">return </span>permissions;
    }
}</pre>
</div>
<p>What I don’t particularly like is only being able to specify the permissions that are available through SharePoint, and not being able to specify my own. What if I wanted to check against Active Directory, or the users’ presence in a group, or validate against a line-of-business application?&#160; It’s not built-in, but Natnael describes a pretty good approach that will allow you to accomplish this.</p>
<p>Alright, now that I have the security in place, I can begin building the application.&#160; I’m going to pretend this application is a front-end to a line-of-business database that manages my Widget inventory.&#160; The focus of the rest of this post is going to be on utilizing some out-of-the-box SharePoint web controls.&#160; Don’t pay <em>too</em> much attention to the implementation of these, as this will serve as an overview of some of the server and user controls that you can leverage.&#160; In future posts I’ll elaborate a little on some of these and provide the nitty-gritty details, but for the sake of brevity I’ll just be covering the basics here.</p>
<p>First, we need to register the controls that we are going to use at the top of the ASPX pages.&#160; This is not a comprehensive list, but should give you the idea:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="background: #ffee62">&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Register </span><span style="color: red">TagPrefix</span><span style="color: blue">=&quot;wssuc&quot; </span><span style="color: red">TagName</span><span style="color: blue">=&quot;InputFormSection&quot; </span><span style="color: red">Src</span><span style="color: blue">=&quot;/_controltemplates/InputFormSection.ascx&quot; </span><span style="background: #ffee62">%&gt;
&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Register </span><span style="color: red">TagPrefix</span><span style="color: blue">=&quot;wssuc&quot; </span><span style="color: red">TagName</span><span style="color: blue">=&quot;InputFormControl&quot; </span><span style="color: red">Src</span><span style="color: blue">=&quot;/_controltemplates/InputFormControl.ascx&quot; </span><span style="background: #ffee62">%&gt;
&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Register </span><span style="color: red">TagPrefix</span><span style="color: blue">=&quot;wssuc&quot; </span><span style="color: red">TagName</span><span style="color: blue">=&quot;ButtonSection&quot; </span><span style="color: red">Src</span><span style="color: blue">=&quot;/_controltemplates/ButtonSection.ascx&quot; </span><span style="background: #ffee62">%&gt;
&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Register </span><span style="color: red">TagPrefix</span><span style="color: blue">=&quot;wssuc&quot; </span><span style="color: red">TagName</span><span style="color: blue">=&quot;ToolBar&quot; </span><span style="color: red">Src</span><span style="color: blue">=&quot;/_controltemplates/ToolBar.ascx&quot; </span><span style="background: #ffee62">%&gt;
&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Register </span><span style="color: red">TagPrefix</span><span style="color: blue">=&quot;wssuc&quot; </span><span style="color: red">TagName</span><span style="color: blue">=&quot;ToolBarButton&quot; </span><span style="color: red">Src</span><span style="color: blue">=&quot;/_controltemplates/ToolBarButton.ascx&quot; </span><span style="background: #ffee62">%&gt;
&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Register </span><span style="color: red">TagPrefix</span><span style="color: blue">=&quot;SharePoint&quot; </span><span style="color: red">Namespace</span><span style="color: blue">=&quot;Microsoft.SharePoint.WebControls&quot;
    </span><span style="color: red">Assembly</span><span style="color: blue">=&quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; </span><span style="background: #ffee62">%&gt;</span></pre>
</div>
<p>
  <br /><strong>Toolbar/SPToolBarButton<br />
    <br /></strong>Many applications have a need for a toolbar, and even SharePoint is littered with them.&#160; You’re able to build one of your own by using the Toolbar.ascx user control (inside the CONTROLTEMPLATES folder), and the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.sptoolbarbutton.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">SPToolBarButton</a> controls (found within the Microsoft.SharePoint.WebControls namespace):</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">Toolbar </span><span style="color: red">id</span><span style="color: blue">=&quot;tb&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;&gt;
    &lt;</span><span style="color: #a31515">Template_Buttons</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">SPToolBarButton
            </span><span style="color: red">ID</span><span style="color: blue">=&quot;btnAdd&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Add Widget&quot;
            </span><span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/add.gif&quot; </span><span style="color: red">NavigateUrl</span><span style="color: blue">=&quot;AddWidget.aspx&quot; /&gt;
        &lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">SPToolBarButton
            </span><span style="color: red">ID</span><span style="color: blue">=&quot;btnRefresh&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Refresh List&quot;
            </span><span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/refresh1.ico&quot; </span><span style="color: red">OnClick</span><span style="color: blue">=&quot;btnRefresh_Click&quot; /&gt;
    &lt;/</span><span style="color: #a31515">Template_Buttons</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Template_RightButtons</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">SPToolBarButton
            </span><span style="color: red">ID</span><span style="color: blue">=&quot;btnHelp&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Help&quot;
            </span><span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/help.gif&quot; </span><span style="color: red">NavigateUrl</span><span style="color: blue">=&quot;Help.aspx&quot;  /&gt;
    &lt;/</span><span style="color: #a31515">Template_RightButtons</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">Toolbar</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />The above markup will render: </p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image56.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="24" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb54.png" width="537" border="0" /></a>&#160; </p>
<p><strong>SPGridView<br />
    <br /></strong>The next control worth mentioning is the all-powerful <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spgridview.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">SPGridView</a> control.&#160; This control is inherited from the ASP.NET GridView control which is already a great control, but the SPGridView provides a ton more functionality.&#160; In supports grouping, it automatically inherits the styles of SharePoint, and you are able to add drop-down menus to your items, like users are already used to in lists and libraries.&#160; The markup syntax is pretty straightforward:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">SPGridView
    </span><span style="color: red">ID</span><span style="color: blue">=&quot;grid&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">AutoGenerateColumns</span><span style="color: blue">=&quot;false&quot; </span><span style="color: red">AllowSorting</span><span style="color: blue">=&quot;true&quot;
    </span><span style="color: red">AllowGrouping</span><span style="color: blue">=&quot;true&quot; </span><span style="color: red">GroupField</span><span style="color: blue">=&quot;Category&quot; </span><span style="color: red">AllowGroupCollapse</span><span style="color: blue">=&quot;true&quot;&gt;

    &lt;</span><span style="color: #a31515">Columns</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField </span><span style="color: red">HeaderText</span><span style="color: blue">=&quot;ID&quot; </span><span style="color: red">DataField</span><span style="color: blue">=&quot;ID&quot; </span><span style="color: red">SortExpression</span><span style="color: blue">=&quot;ID&quot; /&gt;
         &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField
            </span><span style="color: red">HeaderText</span><span style="color: blue">=&quot;Name&quot; </span><span style="color: red">DataField</span><span style="color: blue">=&quot;Name&quot;
            </span><span style="color: red">SortExpression</span><span style="color: blue">=&quot;Name&quot; /&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField
            </span><span style="color: red">HeaderText</span><span style="color: blue">=&quot;Price&quot; </span><span style="color: red">DataField</span><span style="color: blue">=&quot;Price&quot;
            </span><span style="color: red">SortExpression</span><span style="color: blue">=&quot;Price&quot; /&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField
            </span><span style="color: red">HeaderText</span><span style="color: blue">=&quot;Quantity on Hand&quot; </span><span style="color: red">DataField</span><span style="color: blue">=&quot;QuantityOnHand&quot;
            </span><span style="color: red">SortExpression</span><span style="color: blue">=&quot;QuantityOnHand&quot; /&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField
            </span><span style="color: red">HeaderText</span><span style="color: blue">=&quot;Date Added&quot; </span><span style="color: red">DataField</span><span style="color: blue">=&quot;DateAdded&quot;
            </span><span style="color: red">SortExpression</span><span style="color: blue">=&quot;DateAdded&quot; /&gt;
    &lt;/</span><span style="color: #a31515">Columns</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">SPGridView</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />The above markup will render </p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image57.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="329" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb55.png" width="588" border="0" /></a> </p>
<p>Let’s take this a step further and add the familiar drop-down list to the Name column.&#160; There are a ton of examples on how to do this in code-behind, most notably <a href="http://blogs.msdn.com/powlo/default.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/blogs.msdn.com');" target="_blank">Powlo’s</a> posts <a href="http://blogs.msdn.com/powlo/archive/2007/02/25/displaying-custom-data-through-sharepoint-lists-using-spgridview-and-spmenufield.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/blogs.msdn.com');" target="_blank">here</a> and <a href="http://blogs.msdn.com/powlo/archive/2007/03/23/Adding-paging-to-SPGridView-when-using-custom-data-sources.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/blogs.msdn.com');" target="_blank">here</a>, but here’s a little preview on how to do this in the markup.&#160; First, we need to create our <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.menutemplate.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">MenuTemplate</a>, which defines the items in the drop-down list:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">MenuTemplate </span><span style="color: red">ID</span><span style="color: blue">=&quot;menuTemplate&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;&gt;
    &lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">MenuItemTemplate </span><span style="color: red">ID</span><span style="color: blue">=&quot;menuEdit&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;
        </span><span style="color: red">Text</span><span style="color: blue">=&quot;Edit Widget&quot; </span><span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/gear.gif&quot;
        </span><span style="color: red">ClientOnClickScript</span><span style="color: blue">=&quot;javascript:editSomething('%ID%');&quot; /&gt;
    &lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">MenuItemTemplate </span><span style="color: red">ID</span><span style="color: blue">=&quot;menuDelete&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;
        </span><span style="color: red">Text</span><span style="color: blue">=&quot;Delete Widget&quot; </span><span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/delete.gif&quot;
        </span><span style="color: red">ClientOnClickScript</span><span style="color: blue">=&quot;javascript:deleteSomething('%ID%');&quot; /&gt;
&lt;/</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">MenuTemplate</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />Next, replace the BoundField with an <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spmenufield.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">SPMenuField</a>, and specify the menu this is bound to by assigning the MenuTemplateID property to the ID of the menu template we just created.&#160; The TokenNameAndValueFields property assigns a token to a field in the data source.&#160; In this example, I’m declaring two tokens, one for ID and another for Name, which can then be used elsewhere.&#160; The NavigateUrlFields specifies the fields that can be used in the URL set in the NavigateUrlFormat property, and in the same order (it works like the String.Format() method):</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">SharePoint</span><span style="color: blue">:</span><span style="color: #a31515">SPMenuField
    </span><span style="color: red">HeaderText</span><span style="color: blue">=&quot;Name&quot; </span><span style="color: red">TextFields</span><span style="color: blue">=&quot;Name&quot; </span><span style="color: red">MenuTemplateId</span><span style="color: blue">=&quot;menuTemplate&quot;
    </span><span style="color: red">TokenNameAndValueFields</span><span style="color: blue">=&quot;ID=ID,NAME=Name&quot; </span><span style="color: red">NavigateUrlFields</span><span style="color: blue">=&quot;ID&quot;
    </span><span style="color: red">NavigateUrlFormat</span><span style="color: blue">=&quot;EditWidget.aspx?id={0}&quot; /&gt; </span></pre>
</div>
<p>
  <br />The above markup will render: </p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image58.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb56.png" width="566" border="0" /></a>&#160;</p>
<p>
  <br /><strong>Form Fields</strong> </p>
<p>For creating form fields, there are a ton of ways to skin this cat, but I typically choose one of the following two approaches.&#160; Typically your data-entry forms should either look like the forms used for new list items, or the forms for new lists, sites, or pages.&#160; The simplest and arguably cleanest approach is to just use the ASP.NET controls you’re used to, such as a TextBox, DropDownList, etc., and place them in a table that have the SharePoint styles applied to them.&#160; The end result will look something like this:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image59.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="326" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb57.png" width="594" border="0" /></a> </p>
<p>The markup is pretty simple; the important part is is the style classes applied to the elements, specifically ms-formlabel, ms-formbody, and ms-input.&#160; For the sake of brevity, here is a portion of the markup for the above form:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">tr</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">td </span><span style="color: red">class</span><span style="color: blue">=&quot;ms-formlabel&quot;&gt;
      </span>Date Added:
  <span style="color: blue">&lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">td </span><span style="color: red">class</span><span style="color: blue">=&quot;ms-formbody&quot;&gt;
      &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TextBox </span><span style="color: red">id</span><span style="color: blue">=&quot;txtDateAdded&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">CssClass</span><span style="color: blue">=&quot;ms-input&quot; </span><span style="color: red">width</span><span style="color: blue">=&quot;200px&quot; /&gt;
  &lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">tr</span><span style="color: blue">&gt;
&lt;</span><span style="color: #a31515">tr</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">td </span><span style="color: red">class</span><span style="color: blue">=&quot;ms-formlabel&quot;&gt;
      </span>Category:
  <span style="color: blue">&lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">td </span><span style="color: red">class</span><span style="color: blue">=&quot;ms-formbody&quot;&gt;
      &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">DropDownList </span><span style="color: red">id</span><span style="color: blue">=&quot;txtCategory&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">CssClass</span><span style="color: blue">=&quot;ms-input&quot; </span><span style="color: red">width</span><span style="color: blue">=&quot;200px&quot;&gt;
          &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ListItem</span><span style="color: blue">&gt;</span>Cheap Widgets<span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ListItem</span><span style="color: blue">&gt;
          &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ListItem</span><span style="color: blue">&gt;</span>Expensive Widgets<span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ListItem</span><span style="color: blue">&gt;
      &lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">DropDownList</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">tr</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />The second approach is to make the form look like the new list/site pages in SharePoint.&#160; This is perfectly fine too, but takes up a little more space:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image60.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="574" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb58.png" width="594" border="0" /></a></p>
<p>The markup for this is a little more complex, and involves the use of <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.inputformsection.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">InputFormSection</a> and <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.inputformcontrol.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">InputFormControl</a> sections.&#160; A sample of the markup used for the above form is as follows:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormSection </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Title</span><span style="color: blue">=&quot;&quot; </span><span style="color: red">id</span><span style="color: blue">=&quot;dateSection&quot;&gt;
    &lt;</span><span style="color: #a31515">template_description</span><span style="color: blue">&gt;
       &lt;</span><span style="color: #a31515">b</span><span style="color: blue">&gt;</span>Date<span style="color: blue">&lt;/</span><span style="color: #a31515">b</span><span style="color: blue">&gt;&lt;</span><span style="color: #a31515">br </span><span style="color: blue">/&gt;</span>Please specify a date.
    <span style="color: blue">&lt;/</span><span style="color: #a31515">template_description</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">template_inputformcontrols</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormControl </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">LabelText</span><span style="color: blue">=&quot;Date:&quot;&gt;
            &lt;</span><span style="color: #a31515">Template_Control</span><span style="color: blue">&gt;
                &lt;</span><span style="color: #a31515">wssawc</span><span style="color: blue">:</span><span style="color: #a31515">DateTimeControl  </span><span style="color: red">ID</span><span style="color: blue">=&quot;txtDate&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;
                    </span><span style="color: red">DateOnly</span><span style="color: blue">=&quot;true&quot; /&gt;&lt;</span><span style="color: #a31515">BR </span><span style="color: blue">/&gt;
            &lt;/</span><span style="color: #a31515">Template_Control</span><span style="color: blue">&gt;
        &lt;/</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormControl</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">template_inputformcontrols</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormSection</span><span style="color: blue">&gt;  

&lt;</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormSection </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Title</span><span style="color: blue">=&quot;&quot; </span><span style="color: red">id</span><span style="color: blue">=&quot;categorySection&quot;&gt;
    &lt;</span><span style="color: #a31515">template_description</span><span style="color: blue">&gt;
       &lt;</span><span style="color: #a31515">b</span><span style="color: blue">&gt;</span>Category<span style="color: blue">&lt;/</span><span style="color: #a31515">b</span><span style="color: blue">&gt;&lt;</span><span style="color: #a31515">br </span><span style="color: blue">/&gt;</span>Please specify a category
    <span style="color: blue">&lt;/</span><span style="color: #a31515">template_description</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">template_inputformcontrols</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormControl </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">LabelText</span><span style="color: blue">=&quot;Category:&quot;&gt;
            &lt;</span><span style="color: #a31515">Template_Control</span><span style="color: blue">&gt;
                &lt;</span><span style="color: #a31515">wssawc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormTextBox </span><span style="color: red">ID</span><span style="color: blue">=&quot;txtCategory&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;
                    </span><span style="color: red">Columns</span><span style="color: blue">=&quot;40&quot; </span><span style="color: red">class</span><span style="color: blue">=&quot;ms-input&quot;  /&gt;&lt;</span><span style="color: #a31515">BR </span><span style="color: blue">/&gt;
            &lt;/</span><span style="color: #a31515">Template_Control</span><span style="color: blue">&gt;
        &lt;/</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormControl</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">template_inputformcontrols</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">InputFormSection</span><span style="color: blue">&gt; 

&lt;</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">ButtonSection </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">ShowStandardCancelButton</span><span style="color: blue">=&quot;false&quot;&gt;
    &lt;</span><span style="color: #a31515">Template_Buttons</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Button </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">class</span><span style="color: blue">=&quot;ms-ButtonHeightWidth&quot;
            </span><span style="color: red">Text</span><span style="color: blue">=&quot;Save&quot; </span><span style="color: red">id</span><span style="color: blue">=&quot;btnSave&quot; /&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Button </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">class</span><span style="color: blue">=&quot;ms-ButtonHeightWidth&quot;
            </span><span style="color: red">Text</span><span style="color: blue">=&quot;Cancel&quot; </span><span style="color: red">id</span><span style="color: blue">=&quot;btnCancel&quot; </span><span style="color: red">CausesValidation</span><span style="color: blue">=&quot;false&quot; /&gt;
    &lt;/</span><span style="color: #a31515">Template_Buttons</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">wssuc</span><span style="color: blue">:</span><span style="color: #a31515">ButtonSection</span><span style="color: blue">&gt;</span></pre>
</div>
</p>
</p>
</p>
</p>
</p>
</p>
<p>
  <br />As you can see, it’s lot more code, but you’re given a few extra things to work with, like the label and label description to the left, and the extra space to the right.&#160; You’ll also notice I’m using built-in SharePoint controls for the textboxes and the date picker.&#160; There are a bunch of controls that you can leverage, many of which I’ll cover in a future post.&#160; If you’re ambitious though, feel free to poke around the assembly with Reflector or the Object Browser in Visual Studio.&#160; Here’s a screenshot of what you’ll find:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image61.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="432" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb59.png" width="533" border="0" /></a> </p>
<p>There’s all kinds of goodies that are available for us to use in our applications.&#160; Stay tuned for a future post that will dive into a few more of them!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/02/25/integrating-a-custom-aspnet-application-into-sharepoint-part-2/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Integrating a Custom ASP.NET Application into SharePoint (Part 1)</title>
		<link>http://www.devexpertise.com/2009/02/18/integrating-a-custom-aspnet-application-into-sharepoint-part-1/</link>
		<comments>http://www.devexpertise.com/2009/02/18/integrating-a-custom-aspnet-application-into-sharepoint-part-1/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 00:01:45 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Object Model]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint UI]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/2009/02/18/integrating-a-custom-aspnet-application-into-sharepoint-part-1/</guid>
		<description><![CDATA[One of the great things about SharePoint is in addition to all cool stuff it does out-of-the-box, you can add on functionality.&#160; More importantly though, SharePoint can be a great platform to build your own application on top of.&#160; In this series, I will show you how to build a custom ASP.NET application and integrate [...]]]></description>
			<content:encoded><![CDATA[<p>One of the great things about SharePoint is in addition to all cool stuff it does out-of-the-box, you can add on functionality.&#160; More importantly though, SharePoint can be a great platform to build your own application on top of.&#160; In this series, I will show you how to build a custom ASP.NET application and integrate it seamlessly into SharePoint.</p>
<p>The first thing to understand is the location at which we will deploy our custom artifacts.&#160; Since the application will run under the context of a SharePoint site, the files will be deployed to the LAYOUTS folder within the ~12 directory.&#160; There isn’t a need to create a new IIS web site or virtual directory, as it’s using the SharePoint site.</p>
<p>Now, there are different opinions on where certain artifacts should go.&#160; I really don’t think it matters; just personal preference.&#160; One option is to stick with the folder structure that SharePoint uses, and just place a custom folder in each of the destinations that contain your custom artifacts.&#160; Typically this involves placing your files in the following directories: </p>
<div>
<table style="font-size: 8pt; border-collapse: collapse" width="769" border="0">
<colgroup>
<col style="width: 100px" />
<col style="width: 544px" /></colgroup>
<tbody valign="top">
<tr style="background: #dbe5f1">
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: #bfbfbf 0.5pt solid; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151"><span style="font-size: 8pt; font-family: verdana"><strong>Type</strong></span></td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: #bfbfbf 0.5pt solid; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325"><span style="font-size: 8pt; font-family: verdana"><strong>Destination</strong></span>&#160;</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: #bfbfbf 0.5pt solid; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291"><b>Reference Path</b>&#160;</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">.aspx</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">~/_layouts/&lt;ProjectName&gt;/Page.aspx</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">.ascx</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">12\TEMPLATE\CONTROLTEMPLATES\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">~/_controltemplates/&lt;ProjectName&gt;/control.ascx</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">web.config</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">(none)</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">.css</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">12\TEMPLATE\1033\Styles\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">/_layouts/1033/styles/&lt;ProjectName&gt;/style.css</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">.js</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">12\TEMPLATE\LAYOUTS\1033\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">/_layouts/1033/&lt;ProjectName&gt;/script.js</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">.dll</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">Either web app’s BIN directory or GAC</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">(none)</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">Resource DLLs</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">GAC</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">(none)</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">Images</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">12\TEMPLATE\IMAGES\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">/_layouts/images/&lt;ProjectName&gt;/image.gif</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="151">Custom Folders</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="325">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="291">~/_layouts/&lt;ProjectName&gt;/MyFolder/…</td>
</tr>
</tbody>
</table></div>
<p>&#160;</p>
<p>The other option (and my personal preference) is to put everything within a custom folder in the LAYOUTS directory, and only put those files that would require other changes in their respective places.&#160; For example, since a SafeControls entry is required in the web.config for user controls, it makes sense to keep your user controls within that folder.&#160; You could definitely put them inside the LAYOUTS folder with everything else, but then you’d have to create another SafeControls entry. </p>
<div>
<table style="font-size: 8pt; border-collapse: collapse" width="770" border="0">
<colgroup>
<col style="width: 100px" />
<col style="width: 544px" /></colgroup>
<tbody valign="top">
<tr style="background: #dbe5f1">
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: #bfbfbf 0.5pt solid; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147"><span style="font-size: 8pt; font-family: verdana"><strong>Type</strong></span></td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: #bfbfbf 0.5pt solid; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324"><span style="font-size: 8pt; font-family: verdana"><strong>Destination</strong></span>&#160;</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: #bfbfbf 0.5pt solid; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297"><b>Reference Path</b>&#160;</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147"><strong>.</strong>aspx</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">Page.aspx</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">.ascx</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">12\TEMPLATE\CONTROLTEMPLATES\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">~/_controltemplates/&lt;ProjectName&gt;/control.ascx</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">web.config</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">(none)</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">.css</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\Styles\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">Styles/style.css</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">.js</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\Scripts\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">Scripts/script.js</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">.dll</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">Either web app’s BIN directory or GAC</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">(none)</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">Resource DLLs</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">GAC</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">(none)</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">Images</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\Images</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">Images/image.gif</td>
</tr>
<tr>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: #bfbfbf 0.5pt solid; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="147">Custom Folders</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="324">12\TEMPLATE\LAYOUTS\&lt;ProjectName&gt;\</td>
<td style="border-right: #bfbfbf 0.5pt solid; padding-right: 10px; border-top: medium none; padding-left: 10px; padding-bottom: 3px; border-left: medium none; padding-top: 3px; border-bottom: #bfbfbf 0.5pt solid" valign="middle" width="297">MyFolder/…</td>
</tr>
</tbody>
</table></div>
<p>&#160;</p>
<p>Now that the file locations are ironed out, let’s start getting into how to develop the pages.&#160; I will dive into utilizing built-in SharePoint controls, permissions, and some of the fancier stuff in later posts, and will focus on just getting a page to show up within SharePoint.&#160; Your approach to this may differ, but this has proven very effective for me.&#160; First, I create a new web application in Visual Studio, and create a folder structure that mimics SharePoint’s 12 directory:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image52.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="362" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb50.png" width="299" border="0" /></a> </p>
<p>You’ll notice that I have 2 web.config files – one is created when the project is created and can be used to test the project locally, and the other is the one that will be put into SharePoint.&#160; My web.config that goes into SharePoint is very simple and looks like the following.&#160; For testing purposes, I added a test application setting which we’ll retrieve shortly:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot;<span style="color: blue">?&gt;
&lt;</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">system.web </span><span style="color: blue">/&gt;
  &lt;</span><span style="color: #a31515">appSettings</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">add </span><span style="color: red">key</span><span style="color: blue">=</span>&quot;<span style="color: blue">customKey</span>&quot; <span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">Sample Value</span>&quot; <span style="color: blue">/&gt;
  &lt;/</span><span style="color: #a31515">appSettings</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />The next part is probably the most important part of this whole process – setting up the ASPX markup correctly.&#160; Since this page will be integrated into SharePoint’s master page, the same master page/content page principles apply.&#160; The master page contains content place holders which define where page content will go, and the pages themselves define the content that gets inserted in these areas.&#160; SharePoint master pages have a ton of content place holders, most of which we don’t need in a custom application.&#160; The ones that are important are:</p>
<ul>
<li><strong>PlaceHolderAdditionalPageHead</strong>: The content area where custom scripts and styles will be referenced. </li>
<li><strong>PlaceHolderPageTitle</strong>: The title of the page. </li>
<li><strong>PlaceHolderPageTitleInTitleArea</strong>: The text that shows up right above the main content area. </li>
<li><strong>PlaceHolderMain</strong>: The main content area. </li>
<li><strong>PlaceHolderLeftNavBar</strong>: If you want to define your own QuickLaunch or left navigation, you could place it here. </li>
</ul>
<p>Since it’s up to us to define the content within these place holders, all we need to do is add content areas to our ASPX page and put in what we want.&#160; I only used the top 4 aforementioned areas, as I want to utilize the existing quick launch navigation menu:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="background: #ffee62">&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Page </span><span style="color: red">Language</span><span style="color: blue">=&quot;C#&quot; </span><span style="color: red">AutoEventWireup</span><span style="color: blue">=&quot;true&quot; </span><span style="color: red">CodeBehind</span><span style="color: blue">=&quot;Home.aspx.cs&quot;
         </span><span style="color: red">Inherits</span><span style="color: blue">=&quot;DevExpertise.LayoutsApp.Home, DevExpertise.LayoutsApp,
                   Version=1.0.0.0, Culture=neutral, PublicKeyToken=d39eedb6cff9b1c8&quot; </span><span style="background: #ffee62">%&gt;

</span><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content </span><span style="color: red">contentplaceholderid</span><span style="color: blue">=&quot;PlaceHolderAdditionalPageHead&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;&gt;
    &lt;</span><span style="color: #a31515">link </span><span style="color: red">rel</span><span style="color: blue">=&quot;Stylesheet&quot; </span><span style="color: red">type</span><span style="color: blue">=&quot;text/css&quot; </span><span style="color: red">href</span><span style="color: blue">=&quot;Styles/style.css&quot; /&gt;
    &lt;</span><span style="color: #a31515">script </span><span style="color: red">src</span><span style="color: blue">=&quot;Scripts/script.js&quot; </span><span style="color: red">type</span><span style="color: blue">=&quot;text/javascript&quot; /&gt;
&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content</span><span style="color: blue">&gt;

&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content </span><span style="color: red">ContentPlaceHolderID</span><span style="color: blue">=&quot;PlaceHolderPageTitle&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;Server&quot;&gt;
    </span>Page Title - Custom Application
<span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content</span><span style="color: blue">&gt;

&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content </span><span style="color: red">ContentPlaceHolderID</span><span style="color: blue">=&quot;PlaceHolderPageTitleInTitleArea&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;&gt;
    </span>Title Area - Custom Application
<span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content</span><span style="color: blue">&gt;

&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content </span><span style="color: red">ContentPlaceHolderID</span><span style="color: blue">=&quot;PlaceHolderMain&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;&gt;
    &lt;</span><span style="color: #a31515">h1</span><span style="color: blue">&gt;</span>This is a custom application!<span style="color: blue">&lt;/</span><span style="color: #a31515">h1</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TextBox </span><span style="color: red">id</span><span style="color: blue">=&quot;txtValue&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; /&gt;
    &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Button </span><span style="color: red">id</span><span style="color: blue">=&quot;btnSetValue&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Click Me!&quot; </span><span style="color: red">OnClick</span><span style="color: blue">=&quot;btnSetValue_Click&quot; /&gt;
&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Content</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />This doesn’t do much, but will prove the concept.&#160; You can see that I added a custom style sheet (style.css), and also a custom script file (script.js), just so you could see where they go.&#160; In addition, I added a textbox and a button and attached an event handler for the Click event of that button.&#160; In this event handler, I’ll retrieve the web.config setting I mentioned above and set the textbox to this value. The code-behind for this page looks like the following:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">namespace </span>DevExpertise.LayoutsApp {
    <span style="color: blue">public partial class </span><span style="color: #2b91af">Home </span>:System.Web.UI.<span style="color: #2b91af">Page  </span>{

        <span style="color: blue">protected void </span>Page_Load(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e) {
        }

        <span style="color: blue">protected void </span>btnSetValue_Click(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e) {
            txtValue.Text = <span style="color: #2b91af">WebConfigurationManager</span>.AppSettings[<span style="color: #a31515">&quot;customKey&quot;</span>].ToString();
        }
    }
}</pre>
</div>
<p>&#160; <br />Since this code will be executed under the context of SharePoint, the same code access security restrictions apply here as with web parts and custom web services.&#160; You basically have 3 options: adding the assembly to the web application’s BIN directory and setting the trust level to at least WSS_Medium in the web.config, creating a custom code access security policy for your application, or adding the assembly to the GAC.&#160; There are plenty of resources regarding the advantages and disadvantages to each approach out there so I’ll spare you here.&#160; For the sake of simplicity, I added the assembly to the GAC.</p>
<p>Next, I deployed my files to the SharePoint 12 directory.&#160; Since I’m doing this in a development/test environment, I created a handy copy.bat script that uses XCOPY to copy the files to the respective directories.&#160; As soon as this project is ready to be deployed, I’ll run my solution through WSPBuilder and will generate a deployable solution package (.WSP).</p>
<p>After the files are deployed, it’s as simple as typing in the correct URL.&#160; The syntax for this is as follows:</p>
<blockquote>
<p>http://server/site/_layouts/&lt;ProjectFolder&gt;/&lt;PageName&gt;.aspx</p>
</blockquote>
<p>The URL is extremely important when accessing your application pages, as your application <strong>runs under the context of the SharePoint site specified in the URL</strong>.&#160; What does this mean?&#160; Well, if you access your page at <em>http://server/_layouts/MyProject/MyPage.aspx</em>, then it’s running under the context of the site collection’s root site, and accessing SPContext.Current.Web will return that site.&#160; If you access your page at <em>http://server/sites/it/blog/_layouts/MyProject/MyPage.aspx</em>, then it’s running under the context of the blog site under the IT site collection, and SPContext.Current.Web will reflect that.&#160; Why is this important?&#160; Well, since the application pages live in the 12 directory on the farm, they’re globally accessible, and not limited to a single site collection or site.&#160; You could even get to your application at <em>http://CentralAdminUrl/_layouts/MyProject/MyPage.aspx</em>, and it will be running under Central Administration’s context.&#160; Now do you see the importance?&#160; I will show you in a later post how to implement safeguards to mitigate this, but be aware for now that your pages are out there for everyone to access.</p>
<p>For my development machine, I will be accessing this at the following URL:</p>
<blockquote>
<p>http://server/sites/devexpertise/_layouts/DevExpertise.LayoutsApp/Home.aspx</p>
</blockquote>
<p>However, when I try to access this, I get the following:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image53.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="474" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb51.png" width="798" border="0" /></a> </p>
<p>
  <br />No worries &#8212; all this is telling me is that we forgot to specify the master page.&#160; Since this will “inherit” the master page and styles of whichever site it’s accessed from, we must set the master page to that of the current site.&#160; To accomplish this easily for each of my application pages, I create a base LayoutsAppPage that sets the master page:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">namespace </span>DevExpertise.LayoutsApp {
    <span style="color: blue">public class </span><span style="color: #2b91af">LayoutsAppPage </span>: Microsoft.SharePoint.WebControls.<span style="color: #2b91af">LayoutsPageBase </span>{

        <span style="color: blue">protected override void </span>OnPreInit(<span style="color: #2b91af">EventArgs </span>e) {
            <span style="color: blue">base</span>.OnPreInit(e);

            <span style="color: blue">try </span>{
                <span style="color: blue">this</span>.MasterPageFile = <span style="color: #2b91af">SPContext</span>.Current.Web.MasterUrl;
            }
            <span style="color: blue">catch </span>{ }
        }
    }
}</pre>
</div>
</p>
<p>
  <br />You’ll notice that I’m inheriting this from <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.layoutspagebase.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">LayoutsPageBase</a> – this is a base class defined in the Microsoft.SharePoint.WebControls namespace that provides us functionality for creating these types of pages.&#160; That’s beyond the scope of this first post, but I will touch on this later in the series.&#160; Next, I inherit each of my application pages from my custom LayoutsAppPage base class:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 2200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">public partial class </span><span style="color: #2b91af">Home </span>: <span style="color: #2b91af">LayoutsAppPage </span>{

}</pre>
</div>
<p>
  <br />Now if we access the page in the browser, we should get a functioning page.&#160; Clicking the button should retrieve the application setting from the web.config as well:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image55.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="474" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb53.png" width="798" border="0" /></a> </p>
</p>
<p>
  <br />Pretty slick, huh?&#160; Stay tuned for the next posts in this series where we’ll look at how to secure our application and utilize existing SharePoint controls to provide a rich and familiar user interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/02/18/integrating-a-custom-aspnet-application-into-sharepoint-part-1/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Installing a Theme as a SharePoint Feature</title>
		<link>http://www.devexpertise.com/2009/02/11/installing-a-theme-as-a-sharepoint-feature/</link>
		<comments>http://www.devexpertise.com/2009/02/11/installing-a-theme-as-a-sharepoint-feature/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 13:48:53 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint UI]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/2009/02/11/installing-a-theme-as-a-sharepoint-feature/</guid>
		<description><![CDATA[I briefly went over my approach to creating a custom SharePoint theme in my previous post, and I even included a downloadable solution package that you can install on your farm (provided you have the .NET 3.5 Framework installed).&#160; How did I accomplish this?&#160; Pretty easily actually.&#160; Unfortunately there isn’t much documentation or examples of [...]]]></description>
			<content:encoded><![CDATA[<p>I briefly went over my approach to creating a custom SharePoint theme in my <a href="http://www.devexpertise.com/2009/02/09/creating-a-custom-vista-theme-for-sharepoint/"  target="_blank">previous post</a>, and I even included a downloadable solution package that you can install on your farm (provided you have the .NET 3.5 Framework installed).&#160; How did I accomplish this?&#160; Pretty easily actually.&#160; Unfortunately there isn’t much documentation or examples of this out there, so allow me to put an end to that!</p>
<p>SharePoint features and solutions are absolutely essential if you want to provide an easy and maintainable method of deploying custom artifacts to your SharePoint servers.&#160; A theme is a perfect candidate for this, as everything is file-system based and located with the 12 directory.&#160; The only odd thing that throws a monkey wrench in this seemingly simple process is the SPTHEMES.XML file, which must be updated to include an entry for your custom theme.&#160; Here’s a portion of that file, with the custom theme I developed in my previous post highlighted:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image43.png" ><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb41.png" width="653" height="357" /></a></p>
<p>Now, you could by all means include the SPTHEMES.XML file in your solution and have it overwrite the existing file, but what if you have other themes defined in your file?&#160; That approach will overwrite it, and you’ll have to reenter everything.&#160; The recommended approach to this is to create a feature receiver that fires when the feature is installed and modifies the SPTHEMES.XML.&#160; When the feature is installed, a custom &lt;Templates&gt; section is added for the custom theme, and when it’s uninstalled it’s removed.</p>
<blockquote><p>NOTE: A feature is “installed” when you run the <strong>STSADM –o installfeature</strong> command, or when a feature is contained in a solution package and that solution package is <em>deployed</em>.</p>
</blockquote>
<p>One important thing to mention is that this feature is scoped for the farm, not an individual site-collection or site, as the files deployed to the file system are used by the entire farm.&#160; Let’s first take a look at the feature.xml file:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 1200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<pre class="code"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot; <span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot; <span style="color: blue">?&gt;
&lt;</span><span style="color: #a31515">Feature </span><span style="color: red">xmlns</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>&quot;
         <span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">2D965A22-73A9-4e00-A530-06F2AF6EC89F</span>&quot;
         <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise Vista Theme</span>&quot;
         <span style="color: red">Description</span><span style="color: blue">=</span>&quot;<span style="color: blue">Adds the DevExpertise Vista Theme</span>&quot;
         <span style="color: red">Scope</span><span style="color: blue">=</span>&quot;<span style="color: blue">Farm</span>&quot;
         <span style="color: red">Version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0.0.0</span>&quot;
         <span style="color: red">ImageUrl</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise\devexpertiseLogo.png</span>&quot;
         <span style="color: red">ReceiverAssembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise.SharePoint.Themes, Version=1.0.0.0,
                           Culture=neutral, PublicKeyToken=d39eedb6cff9b1c8</span>&quot;
         <span style="color: red">ReceiverClass </span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise.SharePoint.Themes.FeatureReceiver</span>&quot;<span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">Feature</span><span style="color: blue">&gt;</span></pre>
</div>
<p>As you can see, it is executing a custom FeatureReceiver class.&#160; At a high-level, the receiver looks like this:</p>
<p><strong><font color="#ff0000">[UPDATED 5/27/2009]<br />
      <br />I received a couple comments that let me know that if this feature is activated on a farm with multiple front-ends, then the <em>FeatureActivated</em> event only gets fired on a single web front-end.&#160; This is absolutely TRUE, and an oversight on my part (thanks guys!).&#160; The solution is extremely simple – put your code in the <em>FeatureInstalled</em> and <em>FeatureUninstalling</em> events instead, as these get fired on EVERY web front-end in your farm!!&#160; I’ve modified the code to reflect this:</font></strong></p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 1200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">FeatureReceiver</span>: <span style="color: #2b91af">SPFeatureReceiver </span>{

    <span style="color: blue">private enum </span><span style="color: #2b91af">ModificationType </span>{ Add, Remove }

    <span style="color: blue">public override void </span>FeatureInstalled(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
        ModifySPTheme(<span style="color: #2b91af">ModificationType</span>.Add);

        <span style="color: green">// if necessary, loop through all sites and set theme
    </span>}

    <span style="color: blue">public override void </span>FeatureUninstalling(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
        ModifySPTheme(<span style="color: #2b91af">ModificationType</span>.Remove);

        <span style="color: green">// if necessary, loop through all sites and reset theme
    </span>}

    <span style="color: blue">public override void </span>FeatureActivated(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
        <span style="color: green">// do nothing
    </span>}

    <span style="color: blue">public override void </span>FeatureDeactivating(<span style="color: #2b91af">SPFeatureReceiverProperties </span>properties) {
        <span style="color: green">// do nothing
    </span>}
}</pre>
</div>
<p>For the sake of simplicity, I’m not including code to set the theme on any sites.&#160; Since this is a farm feature, it doesn’t make sense to set the theme for a particular site here, but by all means if you wanted to you could.&#160; Basically this feature receiver is only for modifying the SPTHEMES.XML file.</p>
<p>Let’s take a look at the ModifySPTheme() method.&#160; It uses LINQ to XML to open and parse the file, add the necessary elements when the feature is installed, and remove it when the feature is uninstalling:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 2200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<pre class="code"><span style="color: blue">private void </span>ModifySPTheme(<span style="color: #2b91af">ModificationType </span>type) {
    <span style="color: #2b91af">XDocument </span>doc = <span style="color: blue">null</span>;
    <span style="color: #2b91af">XNamespace </span>ns = <span style="color: #a31515">&quot;http://tempuri.org/SPThemes.xsd&quot;</span>;

    <span style="color: green">// path to the SPTHEMES.XML file
    </span><span style="color: blue">string </span>spthemePath = <span style="color: #2b91af">Path</span>.Combine(<span style="color: #2b91af">SPUtility</span>.GetGenericSetupPath(<span style="color: #a31515">@&quot;TEMPLATE\LAYOUTS\1033&quot;</span>), <span style="color: #a31515">&quot;SPTHEMES.XML&quot;</span>);
    <span style="color: blue">string </span>contents = <span style="color: blue">string</span>.Empty;

    <span style="color: green">// read the contents of the SPTHEMES.XML file
    </span><span style="color: blue">using </span>(<span style="color: #2b91af">StreamReader </span>streamReader = <span style="color: blue">new </span><span style="color: #2b91af">StreamReader</span>(spthemePath)) {
        contents = streamReader.ReadToEnd();
        streamReader.Close();
    }

    <span style="color: blue">using </span>(<span style="color: #2b91af">StringReader </span>stringReader = <span style="color: blue">new </span><span style="color: #2b91af">StringReader</span>(contents.Trim())) {
        <span style="color: green">// create a new XDocument from the contents of the file
        </span>doc = <span style="color: #2b91af">XDocument</span>.Load(stringReader);

        <span style="color: green">// retrieve all elements with a TemplateID of 'VISTA'.  At most, there should only be one
        </span><span style="color: blue">var </span>element = <span style="color: blue">from </span>b <span style="color: blue">in </span>doc.Element(ns + <span style="color: #a31515">&quot;SPThemes&quot;</span>).Elements(ns + <span style="color: #a31515">&quot;Templates&quot;</span>)
                      <span style="color: blue">where </span>b.Element(ns + <span style="color: #a31515">&quot;TemplateID&quot;</span>).Value == <span style="color: #a31515">&quot;VISTA&quot;
                      </span><span style="color: blue">select </span>b;

        <span style="color: green">// determine if the VISTA theme element already exists
        </span><span style="color: blue">bool </span>exists = (element != <span style="color: blue">null </span>&amp;&amp; element.Count() &gt; 0);

        <span style="color: blue">if </span>(type == <span style="color: #2b91af">ModificationType</span>.Add) {
            <span style="color: blue">if </span>(!exists) {
                <span style="color: green">// create an XElement that defines our custom VISTA theme
                </span><span style="color: #2b91af">XElement </span>xml =
                    <span style="color: blue">new </span><span style="color: #2b91af">XElement</span>(ns + <span style="color: #a31515">&quot;Templates&quot;</span>,
                        <span style="color: blue">new </span><span style="color: #2b91af">XElement</span>(ns + <span style="color: #a31515">&quot;TemplateID&quot;</span>, <span style="color: #a31515">&quot;VISTA&quot;</span>),
                        <span style="color: blue">new </span><span style="color: #2b91af">XElement</span>(ns + <span style="color: #a31515">&quot;DisplayName&quot;</span>, <span style="color: #a31515">&quot;DevExpertise Vista Theme&quot;</span>),
                        <span style="color: blue">new </span><span style="color: #2b91af">XElement</span>(ns + <span style="color: #a31515">&quot;Description&quot;</span>, <span style="color: #a31515">&quot;A Vista-like Theme&quot;</span>),
                        <span style="color: blue">new </span><span style="color: #2b91af">XElement</span>(ns + <span style="color: #a31515">&quot;Thumbnail&quot;</span>, <span style="color: #a31515">&quot;images/DevExpertise.SharePoint.Themes/VISTA/thVISTA.gif&quot;</span>),
                        <span style="color: blue">new </span><span style="color: #2b91af">XElement</span>(ns + <span style="color: #a31515">&quot;Preview&quot;</span>, <span style="color: #a31515">&quot;images/DevExpertise.SharePoint.Themes/VISTA/thVISTA.gif&quot;</span>));

                <span style="color: green">// add the element to the file and save
                </span>doc.Element(ns + <span style="color: #a31515">&quot;SPThemes&quot;</span>).Add(xml);
                doc.Save(spthemePath);
            }
        }
        <span style="color: blue">else </span>{
            <span style="color: blue">if </span>(exists) {
                <span style="color: green">// if the element exists, remove it and save
                </span>element.Remove();
                doc.Save(spthemePath);
            }
        }

        stringReader.Close();
    }
}</pre>
</div>
<p>Pretty slick, huh? Now, keep in mind that this only modifies the SPTHEMES.XML file – it does NOT set the theme for any site.&#160; It will still be up to the user or site admins to set the theme for a given site.&#160; Also, if this theme is already applied to a site and the feature is deactivated, it won’t reset the theme – it will only remove the entry from the theme settings page in Site Settings.&#160; Finally, if a site has this theme installed and the solution package is uninstalled and/or removed, your site’s theme will be messed up because the source files are gone.&#160; It is probably beneficial to at least loop through all the sites and reset the theme to something else if and when the feature is deactivated, but I’ll leave that to you. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/02/11/installing-a-theme-as-a-sharepoint-feature/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Creating a Custom Vista Theme for SharePoint</title>
		<link>http://www.devexpertise.com/2009/02/09/creating-a-custom-vista-theme-for-sharepoint/</link>
		<comments>http://www.devexpertise.com/2009/02/09/creating-a-custom-vista-theme-for-sharepoint/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 01:01:51 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint UI]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Web Parts]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/2009/02/09/creating-a-custom-vista-theme-for-sharepoint/</guid>
		<description><![CDATA[There are plenty of resources for learning how to create themes for SharePoint.&#160; A theme is a pre-packaged set of styles and images that make your SharePoint site look a little less…well…”SharePoint-y”.&#160; Themes are limited in the respect that they don’t really modify the layout and positioning of your pages, but rather change the colors [...]]]></description>
			<content:encoded><![CDATA[<p>There are plenty of resources for learning how to create themes for SharePoint.&#160; A theme is a pre-packaged set of styles and images that make your SharePoint site look a little less…well…”SharePoint-y”.&#160; Themes are limited in the respect that they don’t really modify the layout and positioning of your pages, but rather change the colors and background images applied to elements.&#160; You can still get pretty fancy with just a theme, but recognize that it’s not enough to completely eliminate the default look and feel.</p>
<p>That said, let’s take a look at theme I put together for the purposes of this blog.&#160; It is loosely based on Vista’s black and aqua stylings, and is aptly named “Vista Theme”.&#160; Before I get into the details about how I approach theme development (since it’s probably not the way you’re used to), let’s take a look at some screenshots of what the finished theme looks like.&#160; In addition, I’m feeling extra generous today and have provided my completed theme for your enjoyment <img src='http://www.devexpertise.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>Home Page:      <br /></em><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image30.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="505" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb28.png" width="720" border="0" /></a> </p>
<p><em>Calendar:</em>     <br /><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image31.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="524" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb29.png" width="720" border="0" /></a></p>
<p><em>Reports Subsite:      <br /></em><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image32.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="504" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb30.png" width="720" border="0" /></a> </p>
<p><em>Document Library:      <br /></em><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image33.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="402" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb31.png" width="720" border="0" /></a> </p>
<p><em>Search Center:      <br /></em><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image34.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="402" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb32.png" width="720" border="0" /></a> </p>
<p><em>Site Actions Menu:      <br /></em><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image35.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="315" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb33.png" width="252" border="0" /></a> </p>
<p><strong>Theme Development</strong>&#160; <br />Ok…now that I’ve [hopefully] gotten your attention, let me discuss what it took to develop this theme.&#160; As you probably know, themes are stored in the following SharePoint directory:</p>
<blockquote><p>C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES\</p>
</blockquote>
<p>In here you’ll find all of the themes that ship with SharePoint out of the box, including GRANITE, SIMPLE, JET, etc..&#160; To create your own theme, the easiest way is to start with a theme you like, copy the folder, and rename it something unique.&#160; In my case, I named it VISTA.&#160; Once you have created your custom folder, it’s imperative you locate the .INF file inside your theme folder, and rename to the name of the folder.&#160; Again, in my case, VISTA.INF.&#160; Next, open it up and change every occurrence of the previous theme’s name, and update it with the name of yours:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image36.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="520" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb34.png" width="238" border="0" /></a> </p>
<p>The next part is a little unorthodox, and I originally saw this <a href="http://www.heathersolomon.com/blog/archive/2008/01/30/SharePoint-2007-Design-Tip-Import-your-CSS-for-SharePoint-Themes.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.heathersolomon.com');" target="_blank">approach described</a> by <a href="http://www.heathersolomon.com/Blog/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.heathersolomon.com');" target="_blank">Heather Solomon</a>, and it has proven extremely useful and efficient.&#160; The idea is to separate the actual theme artifact files (CSS and images) from the theme definition.&#160; The theme definition, which includes every file in the theme folder, is cached whenever the theme is applied to the site.&#160; This means that the only way you can make changes and see them appear is by updating the files in the file system, setting the site’s theme to another theme other than your own, and finally applying your theme again.&#160; Trust me, this is nowhere near ideal when it comes to CSS, as I guarantee you’ll have to try something, test, try something, test, and so on.&#160; The other option is to use SharePoint Designer and modify the cached files, in which case you must remember to update the actual file system files before it gets cached again. The beauty of Heather’s approach is that a single CSS file is cached, and the only thing it contains is a link to a file and the images on the file system in another location which <em>aren’t</em> cached.&#160; This will allow you to make changes directly to the files on the file system and immediately see your changes.</p>
<p>Here is the structure of my Visual Studio solution.&#160; NOTE: The VISTA folder is collapsed due to space, but inside it are all of my images and style sheets:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image37.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="305" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb35.png" width="335" border="0" /></a> </p>
<p>The next steps are typical – create an entry in the SPTHEMES.XML file that identifies your theme, reset IIS or recycle the application pool, and apply your theme.&#160; If all was successful, you should see the following in your site’s theme settings page:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image38.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="273" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb36.png" width="720" border="0" /></a> </p>
<p>One thing I would like to explicitly explain – how to create custom web part headers.&#160; If you pay close attention to the above screenshots, you’ll notice all of my web parts look like this:     <br /><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image39.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="128" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb37.png" width="561" border="0" /></a></p>
<p>This is achieve relatively easily as long as you can create decent-looking header images with your editor of choice (mine is Photoshop).&#160; Basically you need 3 images: a background, a left side, and a right side. Zoomed in, my custom images look like the following:</p>
<p><strong>wp-header-bg.gif:</strong>     <br /><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image40.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb38.png" width="108" border="0" /></a> </p>
<p><strong>wp-header-right.gif</strong>     <br /><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image41.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb39.png" width="108" border="0" /></a> </p>
<p><strong>wp-header-left.gif</strong>     <br /><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image42.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb40.png" width="108" border="0" /></a></p>
<p>The CSS styles are fairly simple:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 1200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: green">/* Web Part Header Styles */
</span><span style="color: #a31515">h3.ms-WPTitle </span>{
    <span style="color: red">background</span>: <span style="color: blue">url('wp-header-left.gif') top left no-repeat</span>;
    <span style="color: red">font-size</span>: <span style="color: blue">8pt</span>;
    <span style="color: red">padding</span>: <span style="color: blue">3px 0px 4px 6px</span>; }    

<span style="color: #a31515">h3.ms-WPTitle</span>, <span style="color: #a31515">h3.ms-WPTitle a</span>, <span style="color: #a31515">h3.ms-WPTitle a:link</span>,
<span style="color: #a31515">h3.ms-WPTitle a:hover</span>, <span style="color: #a31515">h3.ms-WPTitle a:visited</span>{
    <span style="color: red">color</span>:<span style="color: blue">#181818</span>;}    

<span style="color: #a31515">.ms-WPHeader TD </span>{
    <span style="color: red">border-bottom</span>:<span style="color: blue">1px #297c95 solid</span>;
    <span style="color: red">background</span>: <span style="color: blue">url('wp-header-bg.gif') top left repeat-x</span>;
    <span style="color: red">padding-right</span>: <span style="color: blue">0 !important</span>; }        

<span style="color: #a31515">.ms-WPHeader .ms-HoverCellInActive</span>, <span style="color: #a31515">.ms-WPHeader .ms-HoverCellActiveDark </span>{
    <span style="color: red">background</span>: <span style="color: blue">url('wp-header-right.gif')  no-repeat right 0px</span>;
    <span style="color: red">margin-top</span>:<span style="color: blue">0px</span>;
    <span style="color: red">margin-right</span>:<span style="color: blue">0px</span>; }

<span style="color: #a31515">H3.ms-standardheader SPAN </span>{
    <span style="color: red">color</span>: <span style="color: blue">#181818</span>;}

<span style="color: green">/* Web Part Header Hover Image Styles */
</span><span style="color: #a31515">.ms-HoverCellInActive</span>, <span style="color: #a31515">.ms-SpLinkButtonInActive</span>{
    <span style="color: red">padding-right</span>:<span style="color: blue">5px</span>;
    <span style="color: red">padding-top</span>:<span style="color: blue">2px</span>;
    <span style="color: red">margin-bottom</span>:<span style="color: blue">0px</span>; }

<span style="color: #a31515">.ms-HoverCellActiveDark</span>{
    <span style="color: red">border</span>:<span style="color: blue">none</span>;
    <span style="color: red">padding-right</span>:<span style="color: blue">4px</span>;
    <span style="color: red">padding-top</span>:<span style="color: blue">2px</span>; }

<span style="color: #a31515">.ms-HoverCellActiveDark img</span>{
    <span style="color: red">border</span>:<span style="color: blue">1px black solid</span>;
    <span style="color: red">background</span>: <span style="color: blue">#5E5E5E</span>;}     </pre>
</div>
<p>
  <br />The only drawback to including these styles in a theme is these are applied to each and every web part in your site. It may not be appropriate to style all of the web parts, but rather web parts on a single page.&#160; If you only want web parts on a single page to be styled, then you could add the CSS classes to a Content Editor Web Part, or link to the style sheet on the page’s page layout.&#160; The important thing to note is that all web parts on a single page will by styled the same.&#160; There’s no easy way to apply a style to one web part and not the other.&#160; For simplicity sake, I’ve just included these styles in my theme.</p>
<p>You can download this theme and install it via the following farm-scoped feature.&#160; NOTE:&#160; The feature receiver I’m using relies on classes from the .NET 3.5 Framework (you’ll see why in my next post), but this will fail if you try to install it on a farm that doesn’t have 3.5.&#160; If you’re just interested in the source files and style sheets, change the .WSP extension to .CAB and extract the stuff you want.&#160; As I mentioned, I will be explaining how to install a theme via a feature in my next post.&#160; Stay tuned!<br />
  </p>
</p>
<p>&#160;</p>
<div class="wlWriterEditableSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:4c55d70e-29b1-48cd-ae79-96c759a0c371" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<p>Download: <a href="http://www.devexpertise.com/wp-content/uploads/2009/02/devexpertisesharepointthemes1.zip" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2009/02/devexpertisesharepointthemes1.zip');" target="_blank">DevExpertise.SharePoint.Themes</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/02/09/creating-a-custom-vista-theme-for-sharepoint/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
