<?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; ASP.NET</title>
	<atom:link href="http://www.devexpertise.com/tag/aspnet/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>ASP.NET Tip/Trick: Use a Base Page Class for All Application Pages</title>
		<link>http://www.devexpertise.com/2009/03/25/aspnet-tiptrick-use-a-base-page-class-for-all-application-pages/</link>
		<comments>http://www.devexpertise.com/2009/03/25/aspnet-tiptrick-use-a-base-page-class-for-all-application-pages/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 23:31:06 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/2009/03/25/aspnet-tiptrick-use-a-base-page-class-for-all-application-pages/</guid>
		<description><![CDATA[All coders worth their salt know that duplicating code isn’t a best practice, and you should consolidate and leverage object inheritance where necessary.&#160; When done correctly, this promotes better maintainability and a better overall application.
I’ve been doing a lot of straight ASP.NET application programming lately, and no matter how many ASP.NET applications I write, I [...]]]></description>
			<content:encoded><![CDATA[<p>All coders worth their salt know that duplicating code isn’t a best practice, and you should consolidate and leverage object inheritance where necessary.&#160; When done correctly, this promotes better maintainability and a better overall application.</p>
<p>I’ve been doing a lot of straight ASP.NET application programming lately, and no matter how many ASP.NET applications I write, I always use a certain number of common methods in my pages’ code-behind.&#160; For example, I get and set view state values, I retrieve values from the cache, or verify query strings have been included.&#160; Because I’m doing these same types of things in most of my pages, it makes sense to include a lot of the leg work in a base class that each of my pages can inherit.&#160; This blog post will provide you the default base class I always start with, and will explain and demonstrate a few of the methods.</p>
<p>At a high level, my base class is divided into the following four regions:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/image4.png"  rel="lightbox"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/03/image-thumb4.png" width="401" height="274" /></a> </p>
<p><strong>Query String Methods</strong>     <br />Let’s take a look at the Query String Methods first.&#160; Many pages will have support for query strings, and most of the time these query string values will need to be validated.&#160; Consider a scenario where you are accessing data from a database, and you navigate to a page with a URL of <strong>http://webapp/page.aspx?id=10</strong>.&#160; You pull out the ID query string value and pass that in as a parameter and retrieve the appropriate results.&#160; But what if you modify the query string value and access a page with a URL of <strong>http://webapp/page.aspx?id=abc</strong>?&#160; Are you checking to make sure the value is numeric? Are you even checking to make sure an ID query string has been specified?&#160; Well, you should!&#160; A lot of this logic can be wrapped in a base class, and through the use of inheritance and overridden methods, the <em>specific</em> logic can be written.&#160; </p>
<p>I have three methods declared in my base class: </p>
<ul>
<li><strong>RequiredQueryStrings</strong>: Returns a list of all required query string keys. </li>
<li><strong>CheckQueryStrings</strong>: Ensures all required query strings have been specified. </li>
<li><strong>CheckQueryStringValues</strong>: Ensures the specified query string values are actually valid. </li>
</ul>
<p>These methods are declared as follows:</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: gray">/// &lt;summary&gt;
/// </span><span style="color: green">When overriden, returns a list of all required query string keys
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
</span><span style="color: blue">protected virtual </span><span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt; RequiredQueryStrings() {
    <span style="color: blue">return null</span>;
}

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">When overriden, checks the actual values of query strings
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
</span><span style="color: blue">protected virtual bool </span>CheckQueryStringValues() {
    <span style="color: blue">return true</span>;
}

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Verifies the required query string are actually present
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
</span><span style="color: blue">protected bool </span>CheckQueryStrings() {
    <span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt; values = RequiredQueryStrings();

    <span style="color: blue">if </span>(values == <span style="color: blue">null </span>|| values.Count == 0) {
        <span style="color: blue">return true</span>;
    }
    <span style="color: blue">else </span>{
        <span style="color: blue">foreach </span>(<span style="color: blue">string </span>value <span style="color: blue">in </span>values) {
            <span style="color: blue">if </span>(Request.QueryString[value] == <span style="color: blue">null</span>) {
                <span style="color: blue">return false</span>;
            }
        }
    }

    <span style="color: blue">return true</span>;
}</pre>
</div>
<p>
  <br />In addition to these methods, my base page’s Init method checks these methods and depending on the results, allows the rest of the code to run or redirects you to an error page:</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">protected override void </span>OnInit(<span style="color: #2b91af">EventArgs </span>e) {
    <span style="color: blue">base</span>.OnInit(e);

    <span style="color: blue">if </span>(!CheckQueryStrings()) {
        <span style="color: green">// all required query strings have not been specified
        </span>RedirectToPage(<span style="color: #a31515">&quot;Error.aspx&quot;</span>);
    }

    <span style="color: blue">if </span>(!CheckQueryStringValues()) {
        <span style="color: green">// one or more query string values are invalid
        </span>RedirectToPage(<span style="color: #a31515">&quot;Error.aspx&quot;</span>);
    }
}</pre>
</div>
<p>
  <br />To use this, I simply inherit my application pages from my PageBase class, and override the appropriate methods:</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">public partial class </span><span style="color: #2b91af">ViewWidget </span>: <span style="color: #2b91af">PageBase </span>{

    <span style="color: blue">protected override </span><span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt; RequiredQueryStrings() {
        <span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt; values = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt;();
        values.Add(<span style="color: #a31515">&quot;widgetID&quot;</span>);

        <span style="color: blue">return </span>values;
    }

    <span style="color: blue">protected override bool </span>CheckQueryStringValues() {
        <span style="color: blue">int </span>widgetID = 0;
        <span style="color: blue">int</span>.TryParse(Request.QueryString[<span style="color: #a31515">&quot;widgetID&quot;</span>].ToString(), <span style="color: blue">out </span>widgetID);

        <span style="color: blue">return </span>(widgetID &gt; 0);
    }

    <span style="color: blue">protected void </span>Page_Load(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e) { }
}</pre>
</div>
<p>
  <br />Notice all I’m doing is overriding the base class methods, and specifying the things that are required.&#160; It’s up to the base class to do the actual error handling, which in my case involves navigating to an error page.&#160; The important thing to note is that the error handling logic is declared in ONE place.&#160; Each individual page is only responsible for identifying the values that should be checked.</p>
<p>Now, when I access my ViewWidget.aspx page with a valid URL, such as <strong>http://webapp/ViewWidget.aspx?widgetID=10</strong>, I get the following page:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/image5.png"  rel="lightbox"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/03/image-thumb5.png" width="620" height="342" /></a> </p>
<p>
  <br />If I access it with an invalid URL, such as <strong>http://webapp/ViewWidget.aspx?widgetID=xyz</strong>, I get redirected to the error page:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/03/image6.png"  rel="lightbox"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/03/image-thumb6.png" width="620" height="342" /></a> </p>
</p>
<p>&#160;</p>
<p><strong>Redirection Methods</strong> </p>
<p>Chances are your web application contains more than just one page, and you will have to navigate to other pages.&#160; Once in awhile ASP.NET will throw a ThreadAbortException when redirecting to another page, which doesn’t matter, and we don’t really need to do anything when that occurs.&#160; My redirection methods consist of two methods:</p>
<ul>
<li><strong>RedirectToPage</strong>: Redirects to a page and ignores the exception that is sometimes thrown. </li>
<li><strong>RedirectToPageWithQueryStrings</strong>: Redirects to a page and includes all current query string keys and values.&#160; Since this method ultimately calls RedirectToPage, any exception is also ignored. </li>
</ul>
<p>These methods are declared as follows:</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: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Redirects the application to the specified page, and ignores the
</span><span style="color: gray">/// </span><span style="color: green">erroneous error that is sometimes thrown
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;url&quot;&gt;&lt;/param&gt;
</span><span style="color: blue">protected void </span>RedirectToPage(<span style="color: blue">string </span>url){
    <span style="color: blue">try</span>{
        Response.Redirect(url);
    }
    <span style="color: blue">catch</span>{
        <span style="color: green">// catch the ThreadAbortException that is occasionally thrown by ASP.NET
    </span>}
}</pre>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Redirects to another page and carries over all current
</span><span style="color: gray">/// </span><span style="color: green">query string keys and values
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;url&quot;&gt;&lt;/param&gt;
</span><span style="color: blue">protected void </span>RedirectToPageWithQueryStrings(<span style="color: blue">string </span>url) {
    <span style="color: blue">string </span>queryStringList = <span style="color: blue">string</span>.Empty;

    <span style="color: blue">if </span>(!<span style="color: blue">string</span>.IsNullOrEmpty(url)) {
        <span style="color: blue">if </span>(Request.QueryString.Count &gt; 0){

            <span style="color: green">// rebuild the query string list
            </span><span style="color: blue">for</span>(<span style="color: blue">int </span>i = 0; i &lt; Request.QueryString.Count;i++){
                queryStringList += <span style="color: blue">string</span>.Format(<span style="color: #a31515">&quot;{0}={1}&amp;&quot;</span>,
                    Request.QueryString.GetKey(i), Request.QueryString.Get(i));
            }

            <span style="color: green">// remove the erroneous ampersand
            </span>queryStringList = queryStringList.TrimEnd(<span style="color: blue">new char</span>[] { <span style="color: #a31515">'&amp;' </span>});

            <span style="color: green">// append the '?' to the beginning
            </span><span style="color: blue">if </span>(!<span style="color: blue">string</span>.IsNullOrEmpty(queryStringList)) {
                url = <span style="color: #a31515">&quot;?&quot; </span>+ queryStringList;
            }
        }

        RedirectToPage(url);
    }
}</pre>
</div>
<p>&#160;</p>
<p><strong>View State Methods</strong> </p>
<p>I utilize view state occasionally, and have included a couple methods to help manage this:</p>
<ul>
<li><strong>GetViewStateValue</strong>: Retrieves a value from view state, and if it doesn’t exist returns the specified default value. </li>
<li><strong>SetViewStateValue</strong>: Sets a view state value. </li>
<li><strong>ClearViewStateValue</strong>: Clears a view state value. </li>
</ul>
<p>These methods are declared as follows:</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: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Retrieves a value from ViewState
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;key&quot;&gt;&lt;/param&gt;
/// &lt;param name=&quot;defaultValue&quot;&gt;&lt;/param&gt;
/// &lt;returns&gt;&lt;/returns&gt;
</span><span style="color: blue">protected object </span>GetViewStateValue(<span style="color: blue">string </span>key, <span style="color: blue">object </span>defaultValue) {
    <span style="color: blue">return </span>((ViewState[key] == <span style="color: blue">null</span>) ? defaultValue : ViewState[key]);
}

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Sets a value in ViewState
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;key&quot;&gt;&lt;/param&gt;
/// &lt;param name=&quot;val&quot;&gt;&lt;/param&gt;
</span><span style="color: blue">protected void </span>SetViewStateValue(<span style="color: blue">string </span>key, <span style="color: blue">object </span>val) {
    ViewState[key] = val;
}

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Clears a value from ViewState
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;key&quot;&gt;&lt;/param&gt;
</span><span style="color: blue">protected void </span>ClearViewStateValue(<span style="color: blue">string </span>key) {
    ViewState[key] = <span style="color: blue">null</span>;
}</pre>
</div>
<p>&#160;</p>
<p><strong>Cache Methods</strong> </p>
<p>I also leverage the application cache, and have included a few methods to help manage this as well:</p>
<ul>
<li><strong>GetCachedItem</strong>: Retrieves a value from the application cache, and if it doesn’t exist returns null. </li>
<li><strong>SetCachedItem</strong>: Adds an item to the application cache. </li>
<li><strong>ClearCachedItem</strong>: Removes an item from the application cache. </li>
</ul>
<p>These methods are declared as follows:</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: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Returns an item from the application cache
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;key&quot;&gt;&lt;/param&gt;
/// &lt;returns&gt;&lt;/returns&gt;
</span><span style="color: blue">protected object </span>GetCachedItem(<span style="color: blue">string </span>key) {
    <span style="color: blue">object </span>returnValue = <span style="color: blue">null</span>;

    <span style="color: blue">try </span>{
        returnValue = Cache.Get(key);
    }
    <span style="color: blue">catch </span>{ }

    <span style="color: blue">return </span>returnValue;
}

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Adds in item to the application cache
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;key&quot;&gt;&lt;/param&gt;
/// &lt;param name=&quot;value&quot;&gt;&lt;/param&gt;
/// &lt;param name=&quot;minutes&quot;&gt;&lt;/param&gt;
</span><span style="color: blue">protected void </span>SetCachedItem(<span style="color: blue">string </span>key, <span style="color: blue">object </span>value, <span style="color: blue">int </span>minutes) {
    <span style="color: blue">try </span>{
        Cache.Insert(key, value, <span style="color: blue">null</span>,
            <span style="color: #2b91af">DateTime</span>.Now.AddMinutes(minutes), <span style="color: #2b91af">TimeSpan</span>.Zero);
    }
    <span style="color: blue">catch </span>{ }
}

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Clears an item from the application cache
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;key&quot;&gt;&lt;/param&gt;
</span><span style="color: blue">protected void </span>ClearCachedItem(<span style="color: blue">string </span>key) {
    <span style="color: blue">try </span>{
        Cache.Remove(key);
    }
    <span style="color: blue">catch </span>{ }
}</pre>
</div>
<p>&#160;</p>
<p>
  <br />These are just a few of the methods that are good candidates for placement in a base class.&#160; You could just as easily as methods to manage session variables, or some other type of common functionality in your application.&#160; The point is to identify places where you can <em>simplify</em> and <em>reuse</em> code.&#160; This will make it much easier to develop, maintain, and enhance in the future.</p>
<p>I’ve included my base page in the ZIP file below.&#160; As always, my code is provide as-is and without warranty!</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:75751f8d-52db-41a1-980b-e40b696e4ec3" class="wlWriterEditableSmartContent">
<p>Download: <a href="http://www.devexpertise.com/wp-content/uploads/2009/06/pagebase.zip" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2009/06/pagebase.zip');" target="_blank">PageBase.zip</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/03/25/aspnet-tiptrick-use-a-base-page-class-for-all-application-pages/feed/</wfw:commentRss>
		<slash:comments>17</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>
	</channel>
</rss>
