<?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>PeterKellner.net &#187; ASP.NET 2.0</title>
	<atom:link href="http://peterkellner.net/category/aspnet-20/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net</link>
	<description>Microsoft Focused, JavaScript,HTML5 (ExtJS, SenchaTouch &#38; Windows 8 Metro)</description>
	<lastBuildDate>Fri, 11 May 2012 16:43:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to Disable Edit/Insert/New Buttons in DetailsView or GridView (ASP.NET 2.0+)</title>
		<link>http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=detailsview-gridview-aspnet-disable-new-edit-delete-buttons</link>
		<comments>http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 00:27:24 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[DetailsView]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/</guid>
		<description><![CDATA[So, this is kind of embarrassing, that it took me a while to figure this out.&#160; I have not been doing pure asp.net server control programming for a while, but I figure since it took me a while, maybe there is someone else in the same boat.
So, you have a GridView or DetailsView that has [...]]]></description>
			<content:encoded><![CDATA[<p>So, this is kind of embarrassing, that it took me a while to figure this out.&#160; I have not been doing pure asp.net server control programming for a while, but I figure since it took me a while, maybe there is someone else in the same boat.</p>
<p>So, you have a GridView or <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview(VS.80).aspx">DetailsView</a> that has standard “Edit” “Update” “New” type command buttons on them.&#160; The way they get there is by having the declaration something like this:</p>
<p> <span id="more-352"></span>
<pre class="csharpcode"> &lt;asp:DetailsView ID=<span class="str">&quot;DetailsView1&quot;</span> runat=<span class="str">&quot;server&quot;</span> Height=<span class="str">&quot;50px&quot;</span> Width=<span class="str">&quot;125px&quot;</span>
            AllowPaging=<span class="str">&quot;True&quot;</span> AutoGenerateRows=<span class="str">&quot;False&quot;</span> DataKeyNames=<span class="str">&quot;Id&quot;</span>
            DataSourceID=<span class="str">&quot;SqlDataSource1&quot;</span>&gt;
            &lt;Fields&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Id&quot;</span> HeaderText=<span class="str">&quot;Id&quot;</span> ReadOnly=<span class="str">&quot;True&quot;</span>
                    SortExpression=<span class="str">&quot;Id&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Name&quot;</span> HeaderText=<span class="str">&quot;Name&quot;</span> SortExpression=<span class="str">&quot;Name&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampStartDate&quot;</span> HeaderText=<span class="str">&quot;CampStartDate&quot;</span>
                    SortExpression=<span class="str">&quot;CampStartDate&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampEndDate&quot;</span> HeaderText=<span class="str">&quot;CampEndDate&quot;</span>
                    SortExpression=<span class="str">&quot;CampEndDate&quot;</span> /&gt;
                &lt;asp:CommandField ShowEditButton=<span class="str">&quot;True&quot;</span> ShowInsertButton=<span class="str">&quot;True&quot;</span> /&gt;
            &lt;/Fields&gt;
&lt;/asp:DetailsView&gt;</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>What you want is to say something like:</p>
<p>“I only want admin’s to be able to add new rows so&#160; want to hide the “new” button based on that”</p>
<p>So, first thing is to convert the field to a template from the following menu.&#160; You do this by using the little helper in the upper right hand corner of the detailsview (in design mode), chose Edit Fields, CommandField, then convert to template (as in the picture below).</p>
<p><a href="http://peterkellner.net/FilesForWebDownload/HowtoDisableEditInsertNewButtonsinDeta.0_F26A/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/HowtoDisableEditInsertNewButtonsinDeta.0_F26A/image_thumb.png" width="521" height="299" /></a></p>
<p>Then, you will have something like this:</p>
<pre class="csharpcode"> &lt;asp:DetailsView ID=<span class="str">&quot;DetailsView1&quot;</span> runat=<span class="str">&quot;server&quot;</span> Height=<span class="str">&quot;50px&quot;</span> Width=<span class="str">&quot;125px&quot;</span>
            AllowPaging=<span class="str">&quot;True&quot;</span> AutoGenerateRows=<span class="str">&quot;False&quot;</span> DataKeyNames=<span class="str">&quot;Id&quot;</span>
            DataSourceID=<span class="str">&quot;SqlDataSource1&quot;</span>&gt;
            &lt;Fields&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Id&quot;</span> HeaderText=<span class="str">&quot;Id&quot;</span> ReadOnly=<span class="str">&quot;True&quot;</span>
                    SortExpression=<span class="str">&quot;Id&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Name&quot;</span> HeaderText=<span class="str">&quot;Name&quot;</span> SortExpression=<span class="str">&quot;Name&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampStartDate&quot;</span> HeaderText=<span class="str">&quot;CampStartDate&quot;</span>
                    SortExpression=<span class="str">&quot;CampStartDate&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampEndDate&quot;</span> HeaderText=<span class="str">&quot;CampEndDate&quot;</span>
                    SortExpression=<span class="str">&quot;CampEndDate&quot;</span> /&gt;
                &lt;asp:TemplateField ShowHeader=<span class="str">&quot;False&quot;</span>&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:LinkButton ID=<span class="str">&quot;LinkButton1&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span>
                            CommandName=<span class="str">&quot;Edit&quot;</span> Text=<span class="str">&quot;Edit&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                        &amp;nbsp;&lt;asp:LinkButton ID=<span class="str">&quot;LinkButton2&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span>
                            CommandName=<span class="str">&quot;New&quot;</span> Text=<span class="str">&quot;New&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                    &lt;/ItemTemplate&gt;
                    &lt;EditItemTemplate&gt;
                        &lt;asp:LinkButton ID=<span class="str">&quot;LinkButton1&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;True&quot;</span>
                            CommandName=<span class="str">&quot;Update&quot;</span> Text=<span class="str">&quot;Update&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                        &amp;nbsp;&lt;asp:LinkButton ID=<span class="str">&quot;LinkButton2&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span>
                            CommandName=<span class="str">&quot;Cancel&quot;</span> Text=<span class="str">&quot;Cancel&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                    &lt;/EditItemTemplate&gt;
                    &lt;InsertItemTemplate&gt;
                        &lt;asp:LinkButton ID=<span class="str">&quot;LinkButton1&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;True&quot;</span>
                            CommandName=<span class="str">&quot;Insert&quot;</span> Text=<span class="str">&quot;Insert&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                        &amp;nbsp;&lt;asp:LinkButton ID=<span class="str">&quot;LinkButton2&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span>
                            CommandName=<span class="str">&quot;Cancel&quot;</span> Text=<span class="str">&quot;Cancel&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                    &lt;/InsertItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
            &lt;/Fields&gt;
&lt;/asp:DetailsView&gt;</pre>
<p>
  </p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Now, you have standard &lt;asp:LinkButton&gt; so you can call the visible property from your codebehind like this:</p>
<pre class="csharpcode"> <span class="kwrd">&lt;</span><span class="html">asp:TemplateField</span> <span class="attr">ShowHeader</span><span class="kwrd">=&quot;False&quot;</span><span class="kwrd">&gt;</span>
                     <span class="kwrd">&lt;</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span>
                         <span class="kwrd">&lt;</span><span class="html">asp:LinkButton</span> <span class="attr">ID</span><span class="kwrd">=&quot;LinkButton1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">CausesValidation</span><span class="kwrd">=&quot;False&quot;</span> <span class="attr">Visible</span><span class="kwrd">='&lt;%# GetShowEditButton() %&gt;'</span>
                             <span class="attr">CommandName</span><span class="kwrd">=&quot;Edit&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;Edit&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:LinkButton</span><span class="kwrd">&gt;</span>
                         <span class="attr">&amp;nbsp;</span><span class="kwrd">&lt;</span><span class="html">asp:LinkButton</span> <span class="attr">ID</span><span class="kwrd">=&quot;LinkButton2&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">CausesValidation</span><span class="kwrd">=&quot;False&quot;</span> <span class="attr">Visible</span><span class="kwrd">='&lt;%# GetShowInsertButton() %&gt;'</span>
                             <span class="attr">CommandName</span><span class="kwrd">=&quot;New&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;New&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:LinkButton</span><span class="kwrd">&gt;</span>
                         <span class="attr">&amp;nbsp;</span><span class="kwrd">&lt;</span><span class="html">asp:LinkButton</span> <span class="attr">ID</span><span class="kwrd">=&quot;LinkButton3&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">CausesValidation</span><span class="kwrd">=&quot;False&quot;</span>
                             <span class="attr">CommandName</span><span class="kwrd">=&quot;Delete&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;Delete&quot;</span> <span class="attr">Visible</span><span class="kwrd">='&lt;%# GetShowDeleteButton() %&gt;'</span>     <span class="kwrd">&gt;&lt;/</span><span class="html">asp:LinkButton</span><span class="kwrd">&gt;</span>
                     <span class="kwrd">&lt;/</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">asp:TemplateField</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Then, in your codebehind, you have the following:</p>
<pre class="csharpcode"> <span class="kwrd">protected</span> <span class="kwrd">bool</span> GetShowEditButton()
    {
        <span class="kwrd">return</span> Roles.IsUserInRole(<span class="str">&quot;Admin&quot;</span>);
    }

    <span class="kwrd">protected</span> <span class="kwrd">bool</span> GetShowInsertButton()
    {
        <span class="kwrd">return</span> Roles.IsUserInRole(<span class="str">&quot;Admin&quot;</span>);
    }
    <span class="kwrd">protected</span> <span class="kwrd">bool</span> GetShowDeleteButton()
    {
        <span class="kwrd">return</span> Roles.IsUserInRole(<span class="str">&quot;Admin&quot;</span>);
    }
}</pre>
<p>Hope you find this before spending a bunch of time reading about more complicated solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Bravo for ORCSWeb! On so many fronts</title>
		<link>http://peterkellner.net/2009/07/27/orcsweb-hosting-company-awesome-review/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=orcsweb-hosting-company-awesome-review</link>
		<comments>http://peterkellner.net/2009/07/27/orcsweb-hosting-company-awesome-review/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 19:59:07 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[Code Camp Web Site Series]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Sql Server 2008]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/07/27/orcsweb-hosting-company-awesome-review/</guid>
		<description><![CDATA[Many of you know of ORCSWeb either by reputation, or by way of Scott Forsyth, one of my ASP.NET MVP brothers.&#160; In case you don’t, they are a managed hosting solutions company specializing in Microsoft technologies.&#160; I’ve used their basic services for quite a while and have always been very happy.&#160; It has always seemed [...]]]></description>
			<content:encoded><![CDATA[<p>Many of you know of <a href="http://www.orcsweb.com/">ORCSWeb</a> either by reputation, or by way of <a href="http://weblogs.asp.net/owscott/default.aspx">Scott Forsyth</a>, one of my ASP.NET MVP brothers.&#160; In case you don’t, they are a managed hosting solutions company specializing in Microsoft technologies.&#160; I’ve used their basic services for quite a while and have always been very happy.&#160; It has always seemed that anytime I’ve called them (and it always seems like the middle of the night) one of their tech support staff is always available to help me, and go the extra mile if necessary.</p>
<p>The company I’m now working at is small and we don’t have a lot of resources to maintain hardware and do operating system type support.&#160; We do have a high load requirement so we need a very robust supported solution.&#160; Before this, I’d always been in the under $50 per month type plan with ORCSWeb, but I decided I needed more servers and a higher level of support.&#160; I really did not know what level of support to expect when signing up for the managed servers but decided to go for it anyway.</p>
<p>All&#160; can say is <strong>WOW!!!</strong>&#160; I am over the top impressed. </p>
<p> <span id="more-337"></span>
<p>We currently have 3 virtual servers hosted at ORCSWeb.&#160; One, we use as a development server, and the other two are in a webfarm configuration.&#160; I’ve always believed that when you go into production with a web site it’s critical you start with 2 servers in a webfarm.&#160; it’s really easy to go from 2 to 10, but can be very painful to go from 1 to 2.&#160;&#160; That’s a topic for another post, but suffice it to say, 2 is the minimum.</p>
<p>So, why am I so impressed?&#160; First, the support team they assigned to me is totally awesome.&#160; They all are focussed and competent which is a total relief compared with most hosting companies I’ve dealt with.&#160; Other companies always have good people, but it seems to be the bad ones that really give me cause to remember.&#160; Second, because I paid extra for the full managed support options on our three servers, I’ve been able to ask the things like the following.&#160; Almost all of them I could do myself, but I’m swamped with my technology role in the new company and really appreciate being able to hand stuff like this off.</p>
<ul>
<li>I’ve pointed my MX record at my .149 server.&#160; Could you please set up email and create the following 7 accounts. </li>
<li>Please Setup a secure ftp server at the following address with the following username and password (and make sure the user is locked down to the root) </li>
<li>Setup DFS Replication between these two directories on .148 and .149 </li>
<li>Create a RoboCopy script that copies files from my dev server to the .149 mirrored directory </li>
<li>Please set up web statistics for me on <a href="http://www.siliconvalley-codecamp.com">http://www.siliconvalley-codecamp.com</a> </li>
<li>Please figure out why SqlServer 2008 is not letting me access catalog MyStuff1 from user 3p1 and fix </li>
<li>Please make a replicate of website MyWeb1.com including the sqlserver catalog’s and put it on MyWeb2.com on server .149 </li>
<li>Please replace the sqlserver catalog MyStuff3 on server .149 with the bak file I uploaded to my ftp server </li>
<li>I could go on and on, but I think you are getting the idea. </li>
<li>Always with a smile, 24&#215;7, what else can I say. </li>
</ul>
<p>By the way, if you want to see one of my sites hosted there, go to <a href="http://www.siliconvalley-codecamp.com">http://www.siliconvalley-codecamp.com</a></p>
<p>Thank you <a href="http://www.orcsweb.com/">ORCSWeb</a> for making things a lot easier for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/07/27/orcsweb-hosting-company-awesome-review/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ExtJS Meetup Tonight in San Francisco, Sample URLs of Running Code Here</title>
		<link>http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=extjs-meetup-aspnet-code-samples</link>
		<comments>http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/#comments</comments>
		<pubDate>Thu, 14 May 2009 14:47:59 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ObjectDataSource]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/</guid>
		<description><![CDATA[ At tonight&#8217;s meet up, we will be having several short presentations on the new features in ExtJS version 3.0.&#160; For my short presentation, I will be showing how to build a simple asp.net application that lets you Create, Update, Delete and Edit Membership data using the ASP.NET built in membership providers.&#160; I will be [...]]]></description>
			<content:encoded><![CDATA[<p> At tonight&#8217;s meet up, we will be having several short presentations on the new features in <a href="http://extjs.com">ExtJS</a> version 3.0.&#160; For my short presentation, I will be showing how to build a simple asp.net application that lets you Create, Update, Delete and Edit Membership data using the ASP.NET built in membership providers.&#160; I will be leverage code from an MSDN article I wrote a while back here along with the URL to the meetup location.</p>
<p><a title="http://www.meetup.com/The-San-Francisco-ExtJS-Meetup-Group/calendar/10302891/" href="http://www.meetup.com/The-San-Francisco-ExtJS-Meetup-Group/calendar/10302891/">http://www.meetup.com/The-San-Francisco-ExtJS-Meetup-Group/calendar/10302891/</a></p>
<p><a title="http://msdn.microsoft.com/en-us/library/aa478947.aspx" href="http://msdn.microsoft.com/en-us/library/aa478947.aspx">http://msdn.microsoft.com/en-us/library/aa478947.aspx</a></p>
<p>My plan is to do a progression where I start with a trivial GridPanel, then work myself in 5 steps to a full working membership editor that looks like this:</p>
<p> <span id="more-308"></span>
<p><a href="http://peterkellner.net/FilesForWebDownload/ExtJSMeetupTonightinSanFranciscoHereisas_6DA2/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/ExtJSMeetupTonightinSanFranciscoHereisas_6DA2/image_thumb.png" width="392" height="425" /></a></p>
<p>&#160;</p>
<p>If you want to to run the code I will be explaining tonight, here are some links:</p>
<p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorASimpleGrid.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorASimpleGrid.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorASimpleGrid.html</a></p>
<p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorBMoreGrid.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorBMoreGrid.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorBMoreGrid.html</a></p>
<p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorCMoreGridWithPaging.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorCMoreGridWithPaging.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorCMoreGridWithPaging.html</a></p>
<p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorDMoreGridEditing.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorDMoreGridEditing.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorDMoreGridEditing.html</a></p>
<p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorEAddDeleteToolbar.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorEAddDeleteToolbar.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorEAddDeleteToolbar.html</a></p>
<p>If you want a more complete demonstration of ExtJS in general along with more details of the code, I’m presenting a full length version of this at he Bay.Net Meeting in Microsoft next Wednesday evening.&#160; Here are the full details.&#160; These events are both community events are free.</p>
<p><a title="http://www.baynetug.org/DesktopModules/DetailXEvents.aspx?ItemID=378&amp;mid=49" href="http://www.baynetug.org/DesktopModules/DetailXEvents.aspx?ItemID=378&amp;mid=49">http://www.baynetug.org/DesktopModules/DetailXEvents.aspx?ItemID=378&amp;mid=49</a></p>
<p>Hope to see you at one of the events!</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to find your temporary asp.net executing assemblies location</title>
		<link>http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=find-temp-aspnet-assembly-executing-reflection</link>
		<comments>http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 19:22:46 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/</guid>
		<description><![CDATA[Seems, I keep forgetting where the temporary files asp.net uses. The reason it&#8217;s nice to know is sometimes you may want to open them with Reflector to see the generated code.&#160; Also, sometimes, you want to delete those files because asp.net is confused and is reusing old ones.&#160; So, here is the magic lines of [...]]]></description>
			<content:encoded><![CDATA[<p>Seems, I keep forgetting where the temporary files <a href="http://www.asp.net/">asp.net</a> uses. The reason it&#8217;s nice to know is sometimes you may want to open them with <a href="http://www.aisto.com/roeder/dotnet/">Reflector</a> to see the generated code.&#160; Also, sometimes, you want to delete those files because asp.net is confused and is reusing old ones.&#160; So, here is the magic lines of code you need.</p>
<p> <span id="more-136"></span>
<div class="csharpcode">
<pre class="alt">&lt;%@ Page Language=<span class="str">&quot;C#&quot;</span> %&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">&lt;!DOCTYPE html PUBLIC <span class="str">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span class="str">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">&lt;script runat=<span class="str">&quot;server&quot;</span>&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">    <span class="kwrd">protected</span> <span class="kwrd">void</span> Page_Load(<span class="kwrd">object</span> sender, EventArgs e)</pre>
<pre>    {</pre>
<pre class="alt">        LabelWhere.Text = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString();</pre>
<pre>    }</pre>
<pre class="alt">&lt;/script&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">&lt;html xmlns=<span class="str">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</pre>
<pre>&lt;head runat=<span class="str">&quot;server&quot;</span>&gt;</pre>
<pre class="alt">    &lt;title&gt;&lt;/title&gt;</pre>
<pre>&lt;/head&gt;</pre>
<pre class="alt">&lt;body&gt;</pre>
<pre>    &lt;form id=<span class="str">&quot;form1&quot;</span> runat=<span class="str">&quot;server&quot;</span>&gt;</pre>
<pre class="alt">    &lt;div&gt;</pre>
<pre>        &lt;asp:Label ID=<span class="str">&quot;LabelWhere&quot;</span> runat=<span class="str">&quot;server&quot;</span> Text=<span class="str">&quot;Label&quot;</span>&gt;&lt;/asp:Label&gt;</pre>
<pre class="alt">    &lt;/div&gt;</pre>
<pre>    &lt;/form&gt;</pre>
<pre class="alt">&lt;/body&gt;</pre>
<pre>&lt;/html&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Hope this Helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Assigning a Custom Label Value in a ASP.NET GridView Using ObjectDataSource</title>
		<link>http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=assign-label-in-aspdotnet-to-gridview-in-objectdatasource</link>
		<comments>http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 14:10:07 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/</guid>
		<description><![CDATA[In my previous post, Assigning a DropDownList Value in a ASP.NET GridView Using ObjectDataSource, I discussed how to put a DropDownList value in a GridView.&#160; As I explained, my motivation was to answer a common question that appears on often on the forums.&#160; If you are wondering what my process is for deciding what to [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post, <a href="http://peterkellner.net/2008/08/05/assign-dropdownlist-in-aspdotnet-to-gridview-in-objectdatasource/">Assigning a DropDownList Value in a ASP.NET GridView Using ObjectDataSource</a>, I discussed how to put a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dropdownlist(VS.80).aspx">DropDownList</a> value in a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview(VS.80).aspx">GridView</a>.&#160; As I explained, my motivation was to answer a common question that appears on often on the forums.&#160; If you are wondering what my process is for deciding what to answer, there really is no process besides I see yet another question on the forum about this, and rather than answer it again, I write a post explaining it, then point my answer to the question at the post.&#160; This is what I did yesterday and below is the response to this <a href="http://forums.asp.net/p/1300497/2540027.aspx#2540027">forum post</a>.</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/08/x2.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="x" src="http://peterkellner.net/wp/wp-content/uploads/2008/08/x-thumb2.png" width="540" height="208" /></a></p>
<p> <span id="more-129"></span>
<p>So, I have to say one of my main motivations for doing posts is I enjoy helping others through problems.&#160; It gives me a certain satisfaction to know that I have knowledge others may not at any give time and I have a great way to share that knowledge.&#160; It also makes me feel good when others go out of their way to appreciate the effort.&#160; I know when I post questions on forums and get good answers how happy I am, it&#8217;s good to know others appreciate my efforts.</p>
<p>So, continuing down that path, Here is the code necessary to answer Zimbran&#8217;s last question.</p>
<p> <!-- code formatted by http://manoli.net/csharpformat/ --><br />
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}</p>
<p>.csharpcode pre { margin: 0em; }</p>
<p>.csharpcode .rem { color: #008000; }</p>
<p>.csharpcode .kwrd { color: #0000ff; }</p>
<p>.csharpcode .str { color: #006080; }</p>
<p>.csharpcode .op { color: #0000c0; }</p>
<p>.csharpcode .preproc { color: #cc6633; }</p>
<p>.csharpcode .asp { background-color: #ffff00; }</p>
<p>.csharpcode .html { color: #800000; }</p>
<p>.csharpcode .attr { color: #ff0000; }</p>
<p>.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}</p>
<p>.csharpcode .lnum { color: #606060; }</style>
<div class="csharpcode">
<pre class="alt"><span class="asp">&lt;%@ Page Language=&quot;C#&quot; %&gt;</span></pre>
<pre><span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> <span class="kwrd">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> </pre>
<pre class="alt"><span class="kwrd">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span class="kwrd">&gt;</span></pre>
<pre><span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span></pre>
<pre><span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span><span class="kwrd">=&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>
<pre>    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>ODS DDL Example<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span></pre>
<pre><span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span></pre>
<pre class="alt">    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">=&quot;form1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>
<pre>    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>
<pre class="alt">        <span class="kwrd">&lt;</span><span class="html">asp:ObjectDataSource</span> <span class="attr">ID</span><span class="kwrd">=&quot;ObjectDataSource1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> </pre>
<pre>            <span class="attr">SelectMethod</span><span class="kwrd">=&quot;GetMembers&quot;</span></pre>
<pre class="alt">            <span class="attr">TypeName</span><span class="kwrd">=&quot;BusinessObject&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:ObjectDataSource</span><span class="kwrd">&gt;</span></pre>
<pre>        <span class="kwrd">&lt;</span><span class="html">asp:GridView</span> <span class="attr">ID</span><span class="kwrd">=&quot;GridView1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">AutoGenerateColumns</span><span class="kwrd">=&quot;False&quot;</span> </pre>
<pre class="alt">               <span class="attr">DataKeyNames</span><span class="kwrd">=&quot;Id&quot;</span></pre>
<pre>            <span class="attr">DataSourceID</span><span class="kwrd">=&quot;ObjectDataSource1&quot;</span><span class="kwrd">&gt;</span></pre>
<pre class="alt">            <span class="kwrd">&lt;</span><span class="html">Columns</span><span class="kwrd">&gt;</span></pre>
<pre>                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Id&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Id&quot;</span> <span class="attr">ReadOnly</span><span class="kwrd">=&quot;True&quot;</span> </pre>
<pre class="alt">                   <span class="attr">SortExpression</span><span class="kwrd">=&quot;Id&quot;</span> <span class="kwrd">/&gt;</span></pre>
<pre>                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Name&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Name&quot;</span> <span class="attr">SortExpression</span><span class="kwrd">=&quot;Name&quot;</span> <span class="kwrd">/&gt;</span></pre>
<pre class="alt">                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Email&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Email&quot;</span> <span class="attr">SortExpression</span><span class="kwrd">=&quot;Email&quot;</span> <span class="kwrd">/&gt;</span></pre>
<pre>                <span class="kwrd">&lt;</span><span class="html">asp:TemplateField</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Approved&quot;</span> <span class="attr">SortExpression</span><span class="kwrd">=&quot;Approved&quot;</span><span class="kwrd">&gt;</span></pre>
<pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span></pre>
<pre>                        <span class="kwrd">&lt;</span><span class="html">asp:Label</span> <span class="attr">ID</span><span class="kwrd">=&quot;LabelYesOrNo&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> </pre>
<pre class="alt">                           <span class="attr">Text</span><span class="kwrd">='&lt;%# (bool) Eval(&quot;Approved&quot;) ? &quot;Yes&quot; : &quot;No&quot;  %&gt;'</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:Label</span><span class="kwrd">&gt;</span></pre>
<pre>                    <span class="kwrd">&lt;/</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span></pre>
<pre class="alt">                <span class="kwrd">&lt;/</span><span class="html">asp:TemplateField</span><span class="kwrd">&gt;</span></pre>
<pre>            <span class="kwrd">&lt;/</span><span class="html">Columns</span><span class="kwrd">&gt;</span></pre>
<pre class="alt">        <span class="kwrd">&lt;/</span><span class="html">asp:GridView</span><span class="kwrd">&gt;</span></pre>
<pre>    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>
<pre class="alt">    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span></pre>
<pre><span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using LINQ to Merge Mailing Lists and Filter Opt OutsBuilding the Code Camp Web Site (Article 5)</title>
		<link>http://peterkellner.net/2008/07/03/combine-email-lists-with-linq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=combine-email-lists-with-linq</link>
		<comments>http://peterkellner.net/2008/07/03/combine-email-lists-with-linq/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 15:33:39 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[Code Camp Web Site Series]]></category>
		<category><![CDATA[How Things Work]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://peterkellner.net/?p=321</guid>
		<description><![CDATA[<br />
<p>Combining two mailing lists with LINQ, then removing a third is demonstrated in this post.  Using C# 3.0 with .Net 3.5 allows us to leverage LINQ to make this an easy process.  This post shows and explains the LINQ code to do this</p>
<br />]]></description>
			<content:encoded><![CDATA[<h2>Article Series</h2>
<table border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="100">Article 1:</td>
<td valign="top" width="600"><a href="http://peterkellner.net/2008/05/13/codecampwebsiteseries1/" target="_blank">Best Practices for Building an ASP.NET quality web site</a></td>
</tr>
<tr>
<td>Article 2:</td>
<td><a href="http://peterkellner.net/2008/05/19/codecampwebsiteseries2/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters</a></td>
</tr>
<tr>
<td>Article 3:</td>
<td><a href="http://peterkellner.net/2008/05/25/codecampwebsiteseries3/">Creating a Theme For Each Year of Code Camp Using Skins in ASP.NET</a></td>
</tr>
<tr>
<td>Article 4:</td>
<td><a href="http://peterkellner.net/2008/06/29/sv-code-camp-web-site-series4/">Creating a Modal Login Window Using the Telerik Modal RadWindow Component</a></td>
</tr>
<tr>
<td>Article 5:</td>
<td><a href="http://peterkellner.net/2008/07/03/combine-email-lists-with-linq/">Using LINQ to Merge Mailing Lists and Filter Opt Outs</a></td>
</tr>
<tr>
<td>Article 6:</td>
<td><a href="http://peterkellner.net/2009/03/27/codecampwebsiteseries6-cssfriendly-adapters-aspnet-menu/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters (The Source Code!)</a></td>
</tr>
</tbody>
</table>
<p> <br />
<h2>The Problem</h2>
<p>For the third year in a row, <a href="http://www.siliconvalley-codecamp.com/">Silicon Valley&#8217;s Code Camp</a> is happening.&#160; The way I&#8217;ve organized the data is that each year I make a fresh new sql server 2005 database catalog.&#160; this means that I have one for 2006, one for 2007 and a new one for 2008.&#160; I want to do a mailing to all people who have registered to previous code camps and who have not registered yet for this code camp.&#160; This way, I can do multiple mailings without worrying about sending to people that who have registered (which would make me look silly for not knowing they registered already).&#160; I do not like when people say things like &quot;Ignore this message if you have registered&#8230;&quot;.&#160; In addition we will maintain an opt out list so that people who do not want additional emails sent can request that and not worry about us sending more emails.</p>
</p>
<p> <span id="more-122"></span>
</p>
<h2>The Givens</h2>
<p>So, since this article is about how to solve the problem with LINQ, I will not go into details of how to create the generic lists of email addresses.&#160; Let&#8217;s assume we have methods that give us these 4 lists. They are:</p>
<ul>
<li>2006 Registered Attendees </li>
<li>2007 Registered Attendees </li>
<li>2008 Registered Attendees </li>
<li>Opt Out Email List </li>
</ul>
<p>&#160;</p>
<h2>The Code</h2>
<p>Below is the C# version 3.0 (.Net 3.5 and asp.net 3.5) that performs this function described in the problem above.&#160; The next section &quot;The Explanation&quot; gives more details on what i s happening.</p>
<p>&#160;</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">using</span> System.Linq;</pre>
<pre><span class="lnum">   2:  </span>&#160;</pre>
<pre class="alt"><span class="lnum">   3:  </span><span class="rem">/// &lt;summary&gt;</span></pre>
<pre><span class="lnum">   4:  </span><span class="rem">/// shows all non registered users by going </span></pre>
<pre class="alt"><span class="lnum">   5:  </span><span class="rem">/// through past years and making a</span></pre>
<pre><span class="lnum">   6:  </span><span class="rem">/// unique query.</span></pre>
<pre class="alt"><span class="lnum">   7:  </span><span class="rem">/// &lt;/summary&gt;</span></pre>
<pre><span class="lnum">   8:  </span><span class="rem">/// &lt;returns&gt;List of all non-registered </span></pre>
<pre class="alt"><span class="lnum">   9:  </span><span class="rem">/// code campers form previous years&lt;/returns&gt;</span></pre>
<pre><span class="lnum">  10:  </span><span class="kwrd">public</span> <span class="kwrd">static</span> List&lt;ListItem&gt; LoadAllUnRegisteredCodeCampUsers()</pre>
<pre class="alt"><span class="lnum">  11:  </span>{</pre>
<pre><span class="lnum">  12:  </span>&#160;</pre>
<pre class="alt"><span class="lnum">  13:  </span>    List&lt;<span class="kwrd">string</span>&gt; codeCampersCurrentYear = </pre>
<pre><span class="lnum">  14:  </span>        GetEmailsFromPreviousYear(<span class="str">&quot;CodeCampSV06&quot;</span>);</pre>
<pre class="alt"><span class="lnum">  15:  </span>&#160;</pre>
<pre><span class="lnum">  16:  </span>    List&lt;<span class="kwrd">string</span>&gt; emailOptOut2008 = </pre>
<pre class="alt"><span class="lnum">  17:  </span>        GetDoNotRemoveList(<span class="str">&quot;CodeCampSV06&quot;</span>);</pre>
<pre><span class="lnum">  18:  </span>&#160;</pre>
<pre class="alt"><span class="lnum">  19:  </span>    List&lt;<span class="kwrd">string</span>&gt; codeCampers2007 = </pre>
<pre><span class="lnum">  20:  </span>        GetEmailsFromPreviousYear(<span class="str">&quot;PASTSV07&quot;</span>);</pre>
<pre class="alt"><span class="lnum">  21:  </span>&#160;</pre>
<pre><span class="lnum">  22:  </span>    List&lt;<span class="kwrd">string</span>&gt; codeCampers2006 = </pre>
<pre class="alt"><span class="lnum">  23:  </span>        GetEmailsFromPreviousYear(<span class="str">&quot;PASTSV06&quot;</span>);</pre>
<pre><span class="lnum">  24:  </span>&#160;</pre>
<pre class="alt"><span class="lnum">  25:  </span>    <span class="rem">// Make Combined List of 06 and 07 and unique it </span></pre>
<pre><span class="lnum">  26:  </span>    <span class="rem">// (duplicates are removed in Union)</span></pre>
<pre class="alt"><span class="lnum">  27:  </span>    IEnumerable&lt;<span class="kwrd">string</span>&gt; uniqueNamesQuery =</pre>
<pre><span class="lnum">  28:  </span>        codeCampers2006.Union(codeCampers2007).OrderBy(s =&gt; s);</pre>
<pre class="alt"><span class="lnum">  29:  </span>&#160;</pre>
<pre><span class="lnum">  30:  </span>    var emailListBeforeOptOut = </pre>
<pre class="alt"><span class="lnum">  31:  </span>        uniqueNamesQuery.Except(codeCampersCurrentYear);</pre>
<pre><span class="lnum">  32:  </span>&#160;</pre>
<pre class="alt"><span class="lnum">  33:  </span>    var emaiListAfterOptOut = </pre>
<pre><span class="lnum">  34:  </span>        emailListBeforeOptOut.Except(emailOptOut2008);</pre>
<pre class="alt"><span class="lnum">  35:  </span>&#160;</pre>
<pre><span class="lnum">  36:  </span>    List&lt;ListItem&gt;  finalList = <span class="kwrd">new</span> List&lt;ListItem&gt;();</pre>
<pre class="alt"><span class="lnum">  37:  </span>    <span class="kwrd">foreach</span> (<span class="kwrd">string</span> s <span class="kwrd">in</span> emaiListAfterOptOut)</pre>
<pre><span class="lnum">  38:  </span>    {</pre>
<pre class="alt"><span class="lnum">  39:  </span>        finalList.Add(<span class="kwrd">new</span> ListItem(s,s));</pre>
<pre><span class="lnum">  40:  </span>    }</pre>
<pre class="alt"><span class="lnum">  41:  </span>    <span class="kwrd">return</span> finalList;</pre>
<pre><span class="lnum">  42:  </span>}</pre>
<pre class="alt"><span class="lnum">  43:  </span>&#160;</pre>
</div>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<h2>The Explanation</h2>
<p>The first line (1) is required because all the LINQ methods we are using are static extension methods.&#160; This means, that without referencing the LINQ namespace, the methods OrderBy,Except and Union would not be available to us.</p>
<p>Lines 13 to 23 call methods that populate our generic lists of strings.&#160; The reason this is done is because each of these lists come from different <a href="http://www.microsoft.com/SQL/default.mspx">SQL Server 2005</a> database catalogs. This can probably be done in <a href="http://msdn.microsoft.com/en-us/netframework/aa904594.aspx">LINQ</a> but I thought it was easier to do it this way.</p>
<p>Line 27 creates a list of unique names.&#160; The Union method has the added benefit of eliminating duplicates.&#160; OrderBy(s=&gt;s) simply creates an annonymous delegate that takes in a string and returns a string so that is what gets sorted.&#160; After giving this some thought, I&#8217;m not sure the OrderBy really helps us in anyway but this is a tutorial type article so I&#8217;m leaving it in.</p>
<p>Line 33 removes all the people who have asked to be opted out of the email.&#160; It uses the static extension method Except.</p>
<p>Finally, line 36 to 40 creates a generic list of ListItems which is what is returned by the method.&#160; ListItem&#8217;s are returned primarily because the calling method shows a list of checkboxes and this makes it easy.</p>
<p>&#160;</p>
<p>&#160;</p>
<h2>Conclusions</h2>
<p>LINQ is a great tool for managing collections.&#160; In this case we demonstrated how to take 4 generic lists of strings (collections), do some simple set operations (union,except,orderby) and produce a list of emails we want to send.&#160; Not only is it simple to code, it&#8217;s easy to maintain because the method names are so descriptive.&#160;&#160; Hopefully, this will help with your similar programming efforts.&#160; Best of luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/07/03/combine-email-lists-with-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a Theme For Each Year of Code Camp Using Skins in ASP.NETBuilding the New Code Camp Web Site (Part 3)</title>
		<link>http://peterkellner.net/2008/05/25/codecampwebsiteseries3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codecampwebsiteseries3</link>
		<comments>http://peterkellner.net/2008/05/25/codecampwebsiteseries3/#comments</comments>
		<pubDate>Sun, 25 May 2008 22:17:56 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Code Camp Web Site Series]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/05/25/codecampwebsiteseries3/</guid>
		<description><![CDATA[<p>In this post, we discuss how to use themes and skins together in an ASP.NET web site.  A complete example is shown including the web.config, a master page and the theme.skin file.  This is an ongoing series of the trials and tribulations of building a new code camp web site.</p>]]></description>
			<content:encoded><![CDATA[<h2>Article Series</h2>
<table border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="100">Article 1:</td>
<td valign="top" width="600"><a href="http://peterkellner.net/2008/05/13/codecampwebsiteseries1/" target="_blank">Best Practices for Building an ASP.NET quality web site</a></td>
</tr>
<tr>
<td>Article 2:</td>
<td><a href="http://peterkellner.net/2008/05/19/codecampwebsiteseries2/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters</a></td>
</tr>
<tr>
<td>Article 3:</td>
<td><a href="http://peterkellner.net/2008/05/25/codecampwebsiteseries3/">Creating a Theme For Each Year of Code Camp Using Skins in ASP.NET</a></td>
</tr>
<tr>
<td>Article 4:</td>
<td><a href="http://peterkellner.net/2008/06/29/sv-code-camp-web-site-series4/">Creating a Modal Login Window Using the Telerik Modal RadWindow Component</a></td>
</tr>
<tr>
<td>Article 5:</td>
<td><a href="http://peterkellner.net/2008/07/03/combine-email-lists-with-linq/">Using LINQ to Merge Mailing Lists and Filter Opt Outs</a></td>
</tr>
<tr>
<td>Article 6:</td>
<td><a href="http://peterkellner.net/2009/03/27/codecampwebsiteseries6-cssfriendly-adapters-aspnet-menu/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters (The Source Code!)</a></td>
</tr>
</tbody>
</table>
<p> <br />
<h2>Introduction</h2>
<p>Creating themes for ASP.NET 2.0 is very easy if you follow the standard guidelines Microsoft gives us.&#160; Microsoft gives a pretty good discussion in the MSDN article    <br /> <a href="http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx">ASP.NET Themes and Skins Overview</a>.&#160; I&#8217;ve read it several times but since I don&#8217;t do this very often I keep forgetting the simple things.&#160; Recently,     <br /> <a href="http://forums.asp.net/t/1265904.aspx">I posted a question on ASP.NET forums</a> asking how to have an image automatically come from the correct theme directory.&#160; As usual, <a href="http://blogs.ipona.com/davids/Default.aspx">Dave Sussman</a>     <br /> gave me the perfect answer.</p>
<p><em>&quot;You should store the images under the themes and set the ImageUrl in the skin file. Give the control a SkinID in both the skin file and in the page. When the theme changes the appropriate image will be used.&quot;</em></p>
<p>In this article, I&#8217;ll basically explain his answer with an example using the code camp web site.</p>
<p> <span id="more-114"></span> </p>
<h2>Code Camp Site Structure</h2>
<p>The Code Camp project has a very standard directory setup.&#160; In Visual Studio 2008, the solution explorer looks like this:    <br /> <a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/solu.png">     <br /> <img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="solu" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/solu-thumb.png" width="372" height="301" /></a></p>
<p>Notice that I have two themes defined, Gray2008 and Gray2009.&#160; The reason for this is so when 2009 comes along and we want to change certain images that contain things like the Code Camp Date and Year, we don&#8217;t have to do surgery on the asp.net pages, but simply change to the new theme and update the files there.&#160; This also keeps the code base intact so we don&#8217;t have to branch our code for next year.&#160; All in all, a very clean solution.</p>
<h2>The Mechanics of Theme Changing and the Skin Definitions</h2>
<p>First, you have simple mention in your web.config file the name of the default theme you will be using.&#160; By doing that, it references the correct App_Themes sub directory. Our web.config looks like the following for this year which means we will be using the Gray2009 theme directory.</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/webconfigtheme.png">     <br /> <img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="webconfigtheme" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/webconfigtheme-thumb.png" width="479" height="73" /></a></p>
<p>Second, you need to mention a SkinId in any control you may use.&#160; In our case, we want to have the image on the upper right side of the code camp web site display the correct year.&#160; That is, on the home page we have something like this:</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/actualpngforcc.png">     <br /> <img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="actualpngforcc" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/actualpngforcc-thumb.png" width="498" height="134" /></a></p>
<p>The tag in the master page looks like this:</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/imagetag.png">     <br /> <img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="imagetag" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/imagetag-thumb.png" width="577" height="100" /></a></p>
<p>Notice the SkinId circled in green.&#160; Also notice that there is no ImageUrl defined in this tag.&#160; What happens next is that web site will look in the default theme&#8217;s SkinFile.skin file (see the solution explorer above for this).&#160; In the App_Themes/Gray2008/SkinFile.skin file there is a reference that finds the actual image file that will be used.&#160; It reference it from the App_THemes/Gray2008/Images directory as follows:</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/skinfile.png">     <br /> <img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="skinfile" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/skinfile-thumb.png" width="586" height="108" /></a></p>
<p>And, that&#8217;s it!&#160; Just by changing the theme in the web.config file, the correct image file will be displayed in the master page.&#160; The other nice thing is that design time support works also.&#160; You will see in the Visual Studio 2008 Designer the correct image based on where your web.config points.</p>
<h2>Conclusion</h2>
<p>In this article, we&#8217;ve shown the details of how to have a flexible design that    <br /> supports multiple theme files.&#160; Something we will use for years and years with     <br /> the new Code Camp web site.&#160; We also may decide to have different themes for     <br /> different types of users.&#160; That is, admin&#8217;s may have a different theme than     <br /> normal users.&#160; We could also let users pick there own color styles by having     <br /> different themes.&#160; Lots of possibilities.</p>
<p>I hope this helps you.</p>
<p>&#160;</p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre {
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre {
	margin: 0em;
}
.csharpcode .rem {
	color: #008000;
}
.csharpcode .kwrd {
	color: #0000ff;
}
.csharpcode .str {
	color: #006080;
}
.csharpcode .op {
	color: #0000c0;
}
.csharpcode .preproc {
	color: #cc6633;
}
.csharpcode .asp {
	background-color: #ffff00;
}
.csharpcode .html {
	color: #800000;
}
.csharpcode .attr {
	color: #ff0000;
}
.csharpcode .alt {
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum {
	color: #606060;
}</style>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/05/25/codecampwebsiteseries3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Multi Level ASP.NET Menu with CSS Friendly Control AdaptersBuilding the New Code Camp Web Site (Part 2)</title>
		<link>http://peterkellner.net/2008/05/19/codecampwebsiteseries2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codecampwebsiteseries2</link>
		<comments>http://peterkellner.net/2008/05/19/codecampwebsiteseries2/#comments</comments>
		<pubDate>Mon, 19 May 2008 22:38:46 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Code Camp Web Site Series]]></category>
		<category><![CDATA[CSS Adapters]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/05/19/codecampwebsiteseries2/</guid>
		<description><![CDATA[<p>This article discusses the CSS Friendly Adapters and how they are integraged with the ASP.NET 2.0 menu control.  It shows the default html created by a sample menu control without the Friendly Adapters, as well as showing the html created using the Friendly Adapters.</p>]]></description>
			<content:encoded><![CDATA[<h2>Article Series</h2>
<blockquote>
<p><strong><em>(Source Code Available in Article 6 Below &#8211; (Added March 2009))</em></strong></p>
</blockquote>
<table border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="100">Article 1:</td>
<td valign="top" width="600"><a href="http://peterkellner.net/2008/05/13/codecampwebsiteseries1/" target="_blank">Best Practices for Building an ASP.NET quality web site</a></td>
</tr>
<tr>
<td>Article 2:</td>
<td><a href="http://peterkellner.net/2008/05/19/codecampwebsiteseries2/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters</a></td>
</tr>
<tr>
<td>Article 3:</td>
<td><a href="http://peterkellner.net/2008/05/25/codecampwebsiteseries3/">Creating a Theme For Each Year of Code Camp Using Skins in ASP.NET</a></td>
</tr>
<tr>
<td>Article 4:</td>
<td><a href="http://peterkellner.net/2008/06/29/sv-code-camp-web-site-series4/">Creating a Modal Login Window Using the Telerik Modal RadWindow Component</a></td>
</tr>
<tr>
<td>Article 5:</td>
<td><a href="http://peterkellner.net/2008/07/03/combine-email-lists-with-linq/">Using LINQ to Merge Mailing Lists and Filter Opt Outs</a></td>
</tr>
<tr>
<td>Article 6:</td>
<td><a href="http://peterkellner.net/2009/03/27/codecampwebsiteseries6-cssfriendly-adapters-aspnet-menu/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters (The Source Code!)</a></td>
</tr>
</tbody>
</table>
<p></p>
<h2>Introduction</h2>
<div>
<div class="peterkellnerpromo">If you have complex styling issues involving ASP.NET we are experts and might be able to help.  This technique is fairly old however newer methods could be used for similar results. Contact Peter Kellner and his associates <a href="http://peterkellner.net/contactus">here</a>. </div>
<div>
<p>It&#8217;s often the case that brilliant designers will make interfaces that are hard to implement using standard frameworks like ASP.NET.&#160; As Software engineers striving for consistency, we always want to do the best we can with the standard tool kits to take advantage for built in functionality.&#160; <a href="http://asp.net/" target="_blank">ASP.NET 2.0&#8242;s</a> built in menu system is a perfect example.&#160; If you use that menu system, you get to make very simple declarative site maps by simply using the <a href="http://weblogs.asp.net/scottgu/archive/2005/11/20/431019.aspx">ASP.NET 2.0 Site Navigation Features.</a></p>
<p>The requirement faced today has to do with building the web site for our <a href="http://www.siliconvalley-codecamp.com/" target="_blank">third annual code camp</a>.&#160; We have that brilliant designer I mentioned above, and he has made a design that just seems too perfect to compromise.&#160; Here are some screen shots of how the designer envisions the sight looking and working after it is completed.</p>
</p></div>
<p><span id="more-112"></span></p>
<table border="0" cellspacing="0" cellpadding="2" width="800">
<tbody>
<tr>
<td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css1.jpg"><br />
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css1" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css1-thumb.jpg" width="740" height="133" /></a> </p>
<p></td>
</tr>
<tr>
<td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css2.jpg"><br />
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css2" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css2-thumb.jpg" width="741" height="121" /></a> </p>
<p></td>
</tr>
<tr>
<td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css3.jpg"><br />
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css3" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css3-thumb.jpg" width="740" height="136" /></a> </p>
<p></td>
</tr>
<tr>
<td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css4.jpg"><br />
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css4" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css4-thumb.jpg" width="741" height="124" /></a> </p>
<p></td>
</tr>
<tr>
<td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css5.jpg"><br />
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css5" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css5-thumb.jpg" width="748" height="134" /></a> </p>
<p></td>
</tr>
</tbody>
</table>
<p>Notice the interesting behavior of the top menu (REGISTER;PROGRAM;NEWS;ABOUT AND WIKI).&#160; Unselected, the bottom line strip is the same as selected.&#160; When selected, the background of the selection changes to a different shade of the same color as the bottom strip.</p>
<p>Also notice the interesting behavior of the secondary menu. that is, when ABOUT is selected from the top menu, notice that the secondary menu shows: Contact;Venue;Organizers;Sponsors and Previous.&#160; As you can see above (on the bottom of the 5 pictures), when Venu is selected, it is highlighted to in bright white to indicate that you have selected that.&#160; The really cool part here is that the ABOUT on the primary menu stays highlighted when you choose different&#160; secondary menu choices.</p>
<h2>Why Go Through The Trouble, why not just do it with HTML and CSS directly</h2>
<p>So, a reasonable person might say that since you can&#8217;t easily get this behavior with the asp:menu control and the site map provider (OK, at least I couldn&#8217;t figure it out), why not just code this up with simple list items, button clicks and a pile of code to react to those things?&#160; Well, the answer is you can certainly do that.&#160; The problem is the next time you want to do something similar you will find yourself doing a lot of cut and pasting.&#160; Personally, whenever I find myself cutting and pasting a lot I know I should probably think about how to refactor the code to make it more reusable and therefore more reliable.</p>
<h2>What Are the Benefits of Using asp:menu and the site map providers </h2>
<p>I mentioned that there are benefits to using the asp:menu and site map providers.&#160; What are those benefits you might ask.&#160; Well, let me first show you what you have to do to set up a simple menu system using these, then list the benefits of what comes out.</p>
<h3>The Web.SiteMap</h3>
<p>First, you need to create a web.sitemap file in your web directory.&#160; Here is what a simple one looks like similar to what will create the pictures above.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">encoding</span><span class="kwrd">=&quot;utf-8&quot;</span> ?<span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>   <span class="kwrd">&lt;</span><span class="html">siteMap</span> <span class="attr">xmlns</span><span class="kwrd">=&quot;http://schemas.microsoft.com/AspNet/SiteMap-File-1.0&quot;</span> <span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">      <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Default.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;HOME&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;Silicon Valley CodeCamp 08&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Register.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;REGISTER&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;News.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;NEWS&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;About.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;ABOUT&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Contact.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;Contact&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Sponsors.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;Sponsors&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Previous.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;Previous&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre>         <span class="kwrd">&lt;/</span><span class="html">siteMapNode</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">      <span class="kwrd">&lt;/</span><span class="html">siteMapNode</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>   <span class="kwrd">&lt;/</span><span class="html">siteMap</span><span class="kwrd">&gt;</span></pre>
</p></div>
<h3>The Web.Config </h3>
<p>You need to declare which sitemap provider you are using. In our case, we are simply reading from a file.&#160; Then, you should (do not have to) declare a section for each web page you want to provide role access to.&#160; Here is an example of my web.config. This first part says give access to any logged in user for Sponsors.aspx</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">location</span> <span class="attr">path</span><span class="kwrd">=&quot;Sponsors.aspx&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;</span><span class="html">system.web</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">        <span class="kwrd">&lt;</span><span class="html">authorization</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;</span><span class="html">deny</span> <span class="attr">users</span><span class="kwrd">=&quot;?&quot;</span><span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">        <span class="kwrd">&lt;/</span><span class="html">authorization</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;/</span><span class="html">system.web</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt"><span class="kwrd">&lt;/</span><span class="html">location</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre><span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre>
</p></div>
<p>The Second part defines the Site Map Provider and sets securityTrimming to true to only show pages the user has access to.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">system.web</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;</span><span class="html">siteMap</span> <span class="attr">defaultProvider</span><span class="kwrd">=&quot;XmlSiteMapProvider&quot;</span> <span class="attr">enabled</span><span class="kwrd">=&quot;true&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">    <span class="kwrd">&lt;</span><span class="html">providers</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>        <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;XmlSiteMapProvider&quot;</span> </pre>
<p>&#160;</p>
<pre class="alt">        <span class="attr">description</span><span class="kwrd">=&quot;SiteMap provider which reads in .sitemap XML files.&quot;</span> </pre>
<p>&#160;</p>
<pre>        <span class="attr">type</span><span class="kwrd">=&quot;System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0,... </pre>
<p>&#160;</p>
<pre class="alt">        siteMapFile=&quot;</span><span class="attr">web</span>.<span class="attr">sitemap</span><span class="kwrd">&quot; securityTrimmingEnabled=&quot;</span><span class="attr">true</span>&quot;<span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;/</span><span class="html">providers</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">    <span class="kwrd">&lt;/</span><span class="html">siteMap</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>&#160;</pre>
</p></div>
<h3>The Master Page</h3>
<p>In your master page, you need to define your primary menu.&#160; In our case, it is the one that displays: REGISTER;NEWS and ABOUT.&#160; Here is all you need for that.</p>
<div class="csharpcode">
<pre class="alt">    <span class="kwrd">&lt;</span><span class="html">asp:Menu</span> <span class="attr">ID</span><span class="kwrd">=&quot;mainMenu&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">Orientation</span><span class="kwrd">=&quot;Horizontal&quot;</span> </pre>
<p>&#160;</p>
<pre>        <span class="attr">DataSourceID</span><span class="kwrd">=&quot;SiteMapMain&quot;</span> <span class="attr">CssClass</span><span class="kwrd">=&quot;headLinksBar&quot;</span>  <span class="attr">CssSelectorClass</span><span class="kwrd">=&quot;SimpleEntertainmentMenu&quot;</span></pre>
<p>&#160;</p>
<pre class="alt">        <span class="attr">MaximumDynamicDisplayLevels</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">StaticItemFormatString</span><span class="kwrd">=&quot;// {0} &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;/</span><span class="html">asp:Menu</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">asp:SiteMapDataSource</span> <span class="attr">ID</span><span class="kwrd">=&quot;SiteMapMain&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">ShowStartingNode</span><span class="kwrd">=&quot;False&quot;</span> <span class="kwrd">/&gt;</span></pre>
</p></div>
<h3>The Inherited Page (About.aspx For Example)</h3>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">asp:Content</span> <span class="attr">ID</span><span class="kwrd">=&quot;SublinksSessions&quot;</span> <span class="attr">ContentPlaceHolderID</span><span class="kwrd">=&quot;Sublinks&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;</span><span class="html">asp:Menu</span> <span class="attr">ID</span><span class="kwrd">=&quot;subMenu&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">DataSourceID</span><span class="kwrd">=&quot;SiteMapAbout&quot;</span> <span class="attr">SkinID</span><span class="kwrd">=&quot;subMenu&quot;</span>  <span class="attr">CssClass</span><span class="kwrd">=&quot;headLinksBar&quot;</span> </pre>
<p>&#160;</p>
<pre class="alt">    <span class="attr">CssSelectorClass</span><span class="kwrd">=&quot;SimpleEntertainmentMenu&quot;</span>     <span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;/</span><span class="html">asp:Menu</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt"><span class="kwrd">&lt;/</span><span class="html">asp:Content</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>&#160;</pre>
</p></div>
<h3>And the Benefits&#8230;</h3>
<ul>
<li>You have no .net code to write! </li>
<li>Adding new menu items as Primary or Secondary is easy </li>
<li>Security is completely taken care of </li>
<li>Menu Entries Automatically come and go based on User Permission&#160; </li>
</ul>
<h2>Not Using the <a href="http://www.codeplex.com/cssfriendly" target="_blank"></p>
<p>CSS Friendly Adapters</p>
<p>    </a></h2>
<p>If you do not use the CSS Friendly Adapter library, the menu render using tables.&#160; <br />Below is what the actual HTML looks like of the main menu if I remove the</p>
<p><a href="http://www.codeplex.com/cssfriendly" target="_blank">CSS Friendly Adapters</a>.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;#ctl00_mainMenu_SkipLink&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">        <span class="kwrd">&lt;</span><span class="html">img</span> <span class="attr">alt</span><span class="kwrd">=&quot;Skip Navigation Links&quot;</span> <span class="attr">src</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/WebResource.axd?d=G5&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">height</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">style</span><span class="kwrd">=&quot;border-width: 0px;&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">    <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenu&quot;</span> <span class="attr">class</span><span class="kwrd">=&quot;headLinksBar ctl00_mainMenu_2&quot;</span> <span class="attr">cssselectorclass</span><span class="kwrd">=&quot;SimpleEntertainmentMenu&quot;</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>        <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">onmouseover</span><span class="kwrd">=&quot;Menu_HoverStatic(this)&quot;</span> <span class="attr">onmouseout</span><span class="kwrd">=&quot;Menu_Unhover(this)&quot;</span> <span class="attr">onkeyup</span><span class="kwrd">=&quot;Menu_Key(this)&quot;</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenun0&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                        <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;white-space: nowrap;&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                            <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">class</span><span class="kwrd">=&quot;ctl00_mainMenu_1&quot;</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/Register.aspx&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                                // REGISTER</pre>
<p>&#160;</p>
<pre class="alt">                            <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                        <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                    <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;width: 3px;&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">onmouseover</span><span class="kwrd">=&quot;Menu_HoverStatic(this)&quot;</span> <span class="attr">onmouseout</span><span class="kwrd">=&quot;Menu_Unhover(this)&quot;</span> <span class="attr">onkeyup</span><span class="kwrd">=&quot;Menu_Key(this)&quot;</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenun1&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;white-space: nowrap;&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                        <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">class</span><span class="kwrd">=&quot;ctl00_mainMenu_1&quot;</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/News.aspx&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                            // NEWS </pre>
<p>&#160;</p>
<pre>                        <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                    <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;width: 3px;&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">onmouseover</span><span class="kwrd">=&quot;Menu_HoverStatic(this)&quot;</span> <span class="attr">onmouseout</span><span class="kwrd">=&quot;Menu_Unhover(this)&quot;</span> <span class="attr">onkeyup</span><span class="kwrd">=&quot;Menu_Key(this)&quot;</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenun2&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                        <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;white-space: nowrap;&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                            <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">class</span><span class="kwrd">=&quot;ctl00_mainMenu_1&quot;</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/About.aspx&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                                // ABOUT</pre>
<p>&#160;</p>
<pre class="alt">                            <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                        <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                    <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;/</span><span class="html">span</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">        <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre><span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
</p></div>
<p>The same code, when using the <a href="http://www.codeplex.com/cssfriendly" target="_blank">CSS Friendly adapters</a>, plus some clever additions that will be discussed later, has the html code looking like the following.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>    <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">        <span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-Horizontal&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>            <span class="kwrd">&lt;</span><span class="html">ul</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                <span class="kwrd">&lt;</span><span class="html">li</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-TopLevel-register&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly - Copy/Register.aspx&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                      REGISTER</pre>
<p>&#160;</p>
<pre>                     <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span> </pre>
<p>&#160;</p>
<pre class="alt">                <span class="kwrd">&lt;/</span><span class="html">li</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                 <span class="kwrd">&lt;</span><span class="html">li</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-TopLevel-news&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly - Copy/News.aspx&quot;</span><span class="kwrd">&gt;</span>NEWS<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;/</span><span class="html">li</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                <span class="kwrd">&lt;</span><span class="html">li</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-TopLevel-about-Selected&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly - Copy/About.aspx&quot;</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">                      ABOUT<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>                <span class="kwrd">&lt;/</span><span class="html">li</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">ul</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre>         <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre class="alt">     <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<pre> <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
</p></div>
<p>You can see that the CSS adapter code is not only much smaller, but easier to read and because of the inserted class names, much easier to customize.</p>
<h2>Conclusions</h2>
<p>We have not made clear yet how the CSS Friendly Adapters will make the menu&#8217;s work the way we want it to. We have shown css classes created (AspNet-Menu-TopLevel-about-Selected for example) are create by the custom code written by us in the CSS Friendly Adapter Project.&#160; We have however talked about the menu control and showed an example of how the html is actually rendered, and what is rendered based on.&#160; That is, the web.sitemap defines the menu and we have shown that.&#160; In the next article, we will show details of the custom code we have in the CSS Friendly Adapter that solves the problem of how to highlight the menu choices based on what is clicked.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/05/19/codecampwebsiteseries2/feed/</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
		<item>
		<title>Best Practices for Building an asp.net quality web siteBuilding the New Code Camp Web Site (Part 1)</title>
		<link>http://peterkellner.net/2008/05/13/codecampwebsiteseries1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codecampwebsiteseries1</link>
		<comments>http://peterkellner.net/2008/05/13/codecampwebsiteseries1/#comments</comments>
		<pubDate>Tue, 13 May 2008 18:06:25 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Atlas/AJAX]]></category>
		<category><![CDATA[Code Camp Web Site Series]]></category>
		<category><![CDATA[Community]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/05/13/codecampwebsiteseries1/</guid>
		<description><![CDATA[<p>In this article, the first steps for building a professional web site are documented.  These steps include building requirements, working with a designer and starting the process to hire a css/html person</p>]]></description>
			<content:encoded><![CDATA[<p>(That&#8217;s right, Code Camp is coming!&#160; 11/8 and 11/9 again at Foothill College)</p>
<h2>Article Series</h2>
<table border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="100">Article 1:</td>
<td valign="top" width="600"><a href="http://peterkellner.net/2008/05/13/codecampwebsiteseries1/">Best Practices for Building an ASP.NET quality web site</a></td>
</tr>
<tr>
<td>Article 2:</td>
<td><a href="http://peterkellner.net/2008/05/19/codecampwebsiteseries2/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters</a></td>
</tr>
<tr>
<td>Article 3:</td>
<td><a href="http://peterkellner.net/2008/05/25/codecampwebsiteseries3/">Creating a Theme For Each Year of Code Camp Using Skins in ASP.NET</a></td>
</tr>
<tr>
<td>Article 4:</td>
<td><a href="http://peterkellner.net/2008/06/29/sv-code-camp-web-site-series4/">Creating a Modal Login Window Using the Telerik Modal RadWindow Component</a></td>
</tr>
<tr>
<td>Article 5:</td>
<td><a href="http://peterkellner.net/2008/07/03/combine-email-lists-with-linq/">Using LINQ to Merge Mailing Lists and Filter Opt Outs</a></td>
</tr>
<tr>
<td>Article 6:</td>
<td><a href="http://peterkellner.net/2009/03/27/codecampwebsiteseries6-cssfriendly-adapters-aspnet-menu/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters (The Source Code!)</a></td>
</tr>
</tbody>
</table>
<p> 
<p>So, first, a little background.&#160; As many of you know, I&#8217;ve been the ring leader of <a href="http://www.siliconvalley-codecamp.com/">Silicon Valley Code Camp</a> here in northern California for the past 2 years.&#160; Since Code Camp is a limited budget, 100% volunteer effort, the most important thing is to have efficient communications between everyone.&#160; Attendees, Speakers, Organizer, Sponsors and everyone else involved in the event.&#160; To that end, the first code camp web site was created.&#160; It was based on CSS provided by Microsoft.&#160; Check out the post I made two years ago about it titled <a href="http://peterkellner.net/2006/08/28/msprofcsshowto/">&quot;Zero to Professional Web Site in Two Days&quot;</a>.</p>
</p>
<p> <span id="more-111"></span>
</p>
<p>This year, we are planning on a different format.&#160; I don&#8217;t want to give too much away because we have not formally announced the changes, but if you look carefully at the designs, you might get an idea what these changes are going to be.&#160; I&#8217;m getting slightly off topic.&#160; The purpose of this series of articles to take you with me, step by step through building the web site.&#160; This time,    <br />we are going to do it right.&#160; Professional Designer (volunteer) and Professional CSS Implementer (not me, but we do have some budget for this from last year).</p>
<p>So, here are the steps.</p>
<ol>
<li>Decide on what changes need to be made </li>
<li>Work with a professional designer to make mock ups (photoshop, fireworks, etc.) </li>
<li>Create css and html pages from the designers work </li>
<li>Implement the css and html in asp.net </li>
<li>Test </li>
<li>Publish </li>
</ol>
<p>So far, we have done steps 1,2 and are working on step 3.&#160; I&#8217;ve alluded to the requirements above, but don&#8217;t want to spoil too many surprises.&#160; Suffice to say, that is done already.&#160; Step 2 is also now complete.&#160; The professional designer gave us very detailed PSD files that we can turn over to a css wizard.&#160; First, let me show you some of the designs and peek into fireworks to see what is actually under the covers.</p>
<p>First, here are some screen shots of what pages will look like (png files created from the PSD files)</p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="200"><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-home2.png">           <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="svc_home[2]" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-home2-thumb.png" width="244" height="224" /></a>           </td>
<td valign="top" width="200"><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-news.png">           <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="svc_news" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-news-thumb.png" width="244" height="224" /></a>           </td>
</tr>
<tr>
<td valign="top" width="200"><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-reg.png">           <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="svc_reg" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-reg-thumb.png" width="244" height="224" /></a>           </td>
<td valign="top" width="200"><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-sessions.png">           <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="svc_sessions" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/svc-sessions-thumb.png" width="244" height="224" /></a>           </td>
</tr>
</tbody>
</table>
<p>Include is also a PDF file.&#160; It allows the person doing the css and html to really do a good job of pulling the pieces apart to make great web content.</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/fw.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="fw" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/fw-thumb.jpg" width="376" height="445" /></a></p>
<p>(notice the detailed names for all the layers!&#160; this kind of consistency makes it much easier to implement in html and css).</p>
<p>Step 3 is to hand this over to a designer.&#160; I did not have someone to use locally, so I decided to take a shot at using <a href="http://www.rentacoder.com">rentacoder</a>.&#160; I posted a detailed specification which you can see on that site if you navigate to this url:&#160; <a title="http://www.rentacoder.com./RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=924960" href="http://www.rentacoder.com./RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=924960">     <br />http://www.rentacoder.com./RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=924960</a>&#160; </p>
<p>Notice the detailed specifications as well as the 13 bids that have been made ranging from $100 to $1000.&#160; I posted a question on the forums asking if anyone had used any of these services and the response was yes, but don&#8217;t take the lowest bid and also make sure you use someone with lots of experience.&#160; I haven&#8217;t decided next steps yet (that is who to choose), but I will keep posting as I build this web site.</p>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/05/13/codecampwebsiteseries1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Display Images with IIS7 in Vista or Windows 2008</title>
		<link>http://peterkellner.net/2008/04/01/iis7imageproblem/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iis7imageproblem</link>
		<comments>http://peterkellner.net/2008/04/01/iis7imageproblem/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 12:38:59 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Page Handlers]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/04/01/iis7imageproblem/</guid>
		<description><![CDATA[<p>How to solve problem off image not appearing in iis7.  css,gif's, etc.</p>]]></description>
			<content:encoded><![CDATA[<p>So, this may seem simple, but for an hour I wrestled with displaying images on IIS7 with vista.&#160; ASP.NET worked fine, but no static files, css, jpg&#8217;s, gif&#8217;s or anything.&#160; Just unformatted text.</p>
<p>Turns out when I added the web server in vista, I forgot to check the Static Content checkbox under World Wide Web Services / Common Http Features.</p>
<p> <span id="more-107"></span>
<p>Hope this finds you if you are having the same problem.</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/04/webconfig.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="webconfig" src="/wp/wp-content/uploads/2008/04/webconfig-thumb.jpg" width="333" height="297" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/04/01/iis7imageproblem/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Why can I not Bind to a value on a DropDownList in a GridView with ASP.NET 2.0 or 3.5?</title>
		<link>http://peterkellner.net/2007/12/13/gridviewdropdownlistrow/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gridviewdropdownlistrow</link>
		<comments>http://peterkellner.net/2007/12/13/gridviewdropdownlistrow/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 00:26:44 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[How Things Work]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/12/13/gridviewdropdownlistrow/</guid>
		<description><![CDATA[<p>Learn how to bind a DropDownList in an asp.net 2.0/3.5 GridView Edit Row.  This will show you how to get the data back to the database and learn why Bind does not help you (hint:  SelectedValue is not our friend here).</p>]]></description>
			<content:encoded><![CDATA[<p>So, I guess I should have know the answer to why the following does not work.&nbsp; Basically, the scenario I have is that I have a foreign key column in my GridView that I want to show as a DropDownList of values.&nbsp; The code below shows me the values in the DropDownList, but when I update it with the &#8220;edit&#8221; of the GridView row, the value does not get saved.&nbsp; Here is the code and what it looks like running:</p>
<p> <span id="more-90"></span>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">&lt;</span><span class="html">asp:TemplateField</span> <span class="attr">HeaderText</span><span class="kwrd">="TemplateUsersId"</span> <span class="attr">SortExpression</span><span class="kwrd">="TemplateUsersId"</span><span class="kwrd">&gt;</span>      <span class="kwrd">&lt;</span><span class="html">EditItemTemplate</span><span class="kwrd">&gt;</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">       <span class="kwrd">&lt;</span><span class="html">asp:DropDownList</span> <span class="attr">ID</span><span class="kwrd">="DropDownListUser"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">AutoPostBack</span><span class="kwrd">="False"</span> <span class="attr">DataSourceID</span><span class="kwrd">="SqlDataSourceUser"</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">            <span class="attr">DataTextField</span><span class="kwrd">="Username"</span> <span class="attr">DataValueField</span><span class="kwrd">="id"</span> <span class="attr">SelectedValue</span><span class="kwrd">='&lt;%# Bind("TemplateUsersId") %&gt;'</span><span class="kwrd">&gt;</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">         <span class="kwrd">&lt;/</span><span class="html">asp:DropDownList</span><span class="kwrd">&gt;</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">         ..</pre>
</div>
<p>Notice that even though I&#8217;m using Bind rather than eval, the value does not stick.&nbsp; Well, we always have a reason so I believe it is not working because SelectedValue only has a Get (it&#8217;s read only) and the value can not be put back.&nbsp; So, the solution that works for me is to program the GridView&#8217;s Updating Row Event.&nbsp; That is, get the value from the dropdownlist, and set it in the event.&nbsp; Here is the code that is working for me.</p>
<div class="csharpcode">
<pre class="alt"> <span class="rem">/// &lt;summary&gt;    /// This Code Gets the value of the DropDownList in the EditItemTemplate.</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">    <span class="rem">/// &lt;/summary&gt;</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">    <span class="rem">/// &lt;param name="sender"&gt;&lt;/param&gt;</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">    <span class="rem">/// &lt;param name="e"&gt;&lt;/param&gt;</span></pre>
<pre>&nbsp;</pre>
<pre class="alt">    <span class="kwrd">protected</span> <span class="kwrd">void</span> GridViewIncomingUrls_RowUpdating(<span class="kwrd">object</span> sender, GridViewUpdateEventArgs e)</pre>
<pre>&nbsp;</pre>
<pre class="alt">    {</pre>
<pre>&nbsp;</pre>
<pre class="alt">        DropDownList dropDownListUser = GridViewIncomingUrls.Rows[e.RowIndex].FindControl(<span class="str">"DropDownListUser"</span>) <span class="kwrd">as</span> DropDownList;</pre>
<pre>&nbsp;</pre>
<pre class="alt">        e.NewValues[<span class="str">"TemplateUsersId"</span>] = dropDownListUser.SelectedValue;</pre>
<pre>&nbsp;</pre>
<pre class="alt">    }</pre>
</div>
<p>Yee Ha! it works. Hope you don&#8217;t have to suffer like me and just bump into this solution</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/12/13/gridviewdropdownlistrow/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Really good Ajax using asp.net Book By Alessandro Gallo, ASP.NET AJAX in Action</title>
		<link>http://peterkellner.net/2007/11/26/ajaxinactionbookreview/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ajaxinactionbookreview</link>
		<comments>http://peterkellner.net/2007/11/26/ajaxinactionbookreview/#comments</comments>
		<pubDate>Mon, 26 Nov 2007 18:29:19 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Atlas/AJAX]]></category>
		<category><![CDATA[Book Reviews]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/11/26/ajaxinactionbookreview/</guid>
		<description><![CDATA[<br /><p>Alessandro Gallo has written a great book on Ajax in ASP.NET.  I strongly recommend this book.  Read on for more details.</p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m basically a back end database kind of guy, but over the past years have been doing more front end web stuff.&#160; Asp.Net has been a huge help for me, and now with Visual Studio 2008 and the JavaScript debugging capabilities, I&#8217;m finding doing web stuff is just not so bad.&#160; Many of you know I&#8217;ve written several MSDN articles and one of them was over a year ago on how to add Ajax to my Membership solution (back then it was called Atlas).&#160; The <a title="Third Article Published on MSDN! ASP.NET 2.0, Membership Meets Atlas" href="http://peterkellner.net/2006/08/02/third-article-published-on-msdn-aspnet-20-membership-meets-atlas/">article</a> is still out there though now a little out dated.&#160; In it, I extensively use Alessandro&#8217;s code he posted on his blog.&#160; My point here is Alessandro keeps up with this stuff, and as it turns out, he wrote an excellent book that&#8217;s been helping me out.</p>
<p>I enthusiastically recommend it to anyone trying to incorporate Ajax into their asp.net applications.&#160; It&#8217;s not only got a great introduction, but also goes into lots of useful details for day to day programming.</p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="400"><a title="Amazon.com: ASP.NET AJAX in Action" href="http://www.amazon.com/exec/obidos/ASIN/1933988142/petkelsblo-20"><img border="0" align="left" src="http://images.amazon.com/images/P/1933988142.01.MZZZZZZZ.jpg" />Amazon.com: ASP.NET AJAX in Action</a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/11/26/ajaxinactionbookreview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Display Checkboxes in ASP.NET 2.0 GridView using skins</title>
		<link>http://peterkellner.net/2007/11/23/gridviewskincheckbox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gridviewskincheckbox</link>
		<comments>http://peterkellner.net/2007/11/23/gridviewskincheckbox/#comments</comments>
		<pubDate>Sat, 24 Nov 2007 01:02:49 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/11/23/gridviewskincheckbox/</guid>
		<description><![CDATA[<br /><p> This article shows how to take advantage of skin files to make checkboxes show up in gridview as checked, unchecked, enabled and disabled.  It's tricky because skin files can not be changed dynamically at runtime. </p><br />]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve been struggling for a while with how to style a checkbox to work with a skin file. Basically, what I did was create some gif files that look like checked and unchecked check boxes. I defined them in my SkinFile.skin file as follows:</p>
<p style="margin: 0px; font-family: courier new; background: white; color: black; font-size: 10pt"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ImageButton</span> <span style="color: red">SkinID</span><span style="color: blue">=&quot;iconCheckedDisabled&quot;</span> <span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/iconCheckedDisabled.gif&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">ToolTip</span><span style="color: blue">=&quot;Checked Disabled&quot;</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px; font-family: courier new; background: white; color: black; font-size: 10pt"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ImageButton</span> <span style="color: red">SkinID</span><span style="color: blue">=&quot;iconCheckedEnabled&quot;</span> <span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/iconCheckedEnabled.gif&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">ToolTip</span><span style="color: blue">=&quot;Checked Enabled&quot;</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px; font-family: courier new; background: white; color: black; font-size: 10pt"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ImageButton</span> <span style="color: red">SkinID</span><span style="color: blue">=&quot;iconUnCheckedDisabled&quot;</span> <span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/iconUnCheckedDisabled.gif&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">ToolTip</span><span style="color: blue">=&quot;Unchecked Disabled&quot;</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px; font-family: courier new; background: white; color: black; font-size: 10pt"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ImageButton</span> <span style="color: red">SkinID</span><span style="color: blue">=&quot;iconUnCheckedEnabled&quot;</span> <span style="color: red">ImageUrl</span><span style="color: blue">=&quot;Images/iconUnCheckedEnabled.gif&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">ToolTip</span><span style="color: blue">=&quot;Unchecked Enabled&quot;</span> <span style="color: blue">/&gt;</span></p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt"></div>
<p>The image files look like the following:</p>
<p> <span id="more-85"></span>
<p><a title="iconUncheckedDisabled.gif" href="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconuncheckeddisabled.gif" rel="lightbox"><img id="urn:zoundry:jid:iconUncheckedDisabled.gif" title="iconUncheckedDisabled.gif" border="0" alt="iconUncheckedDisabled.gif" src="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconuncheckeddisabled-tn.jpg" width="15" height="15" /></a> <a title="iconCheckedDisabled.gif" href="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconcheckeddisabled.gif" rel="lightbox"><img id="urn:zoundry:jid:iconCheckedDisabled.gif" title="iconCheckedDisabled.gif" border="0" alt="iconCheckedDisabled.gif" src="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconcheckeddisabled-tn.jpg" width="15" height="15" /></a> <a title="iconUncheckedEnabled.gif" href="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconuncheckedenabled.gif" rel="lightbox"><img id="urn:zoundry:jid:iconUncheckedEnabled.gif" title="iconUncheckedEnabled.gif" border="0" alt="iconUncheckedEnabled.gif" src="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconuncheckedenabled-tn.jpg" width="15" height="15" /></a> <a title="iconCheckedEnabled.gif" href="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconcheckedenabled.gif" rel="lightbox"><img id="urn:zoundry:jid:iconCheckedEnabled.gif" title="iconCheckedEnabled.gif" border="0" alt="iconCheckedEnabled.gif" src="http://peterkellner.net/wp/wp-content/uploads/2007/11/iconcheckedenabled-tn.jpg" width="15" height="15" /></a></p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">&#160;</div>
<p>The problem basically is that you can&#8217;t dynamically swap skin files easily because they must be set at the preinit phase of event processing. Not at databound events which is where I&#8217;d want to do it.</p>
<p>So, my revelation was that I could just list all the states in a gridview template, then use the visibility attribute to make them show the correct one. That way, the skins are all loaded all the time, just now showing all the time. The GridView Code looks like the following:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt"></div>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">GridView</span> <span style="color: red">ID</span><span style="color: blue">=&quot;GridViewAssigned&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">AllowPaging</span><span style="color: blue">=&quot;True&quot;</span></p>
<p style="margin: 0px"><span style="color: red">AllowSorting</span><span style="color: blue">=&quot;True&quot;</span> <span style="color: red">Caption</span><span style="color: blue">=&quot;Assigned&quot;</span> <span style="color: red">AutoGenerateColumns</span><span style="color: blue">=&quot;false&quot;</span></p>
<p style="margin: 0px"><span style="color: red">DataSourceID</span><span style="color: blue">=&quot;ObjectDataSourceGroupsAssigned&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">Columns</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TemplateField</span> <span style="color: red">ShowHeader</span><span style="color: blue">=&quot;False&quot;</span> <span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ImageButton</span> <span style="color: red">ID</span><span style="color: blue">=&quot;LinkButtonUnassign&quot;</span> <span style="color: red">SkinID</span><span style="color: blue">=&quot;ImageButtonRemove&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">BackColor</span><span style="color: blue">=&quot;white&quot;</span> <span style="color: red">CausesValidation</span><span style="color: blue">=&quot;False&quot;</span></p>
<p style="margin: 0px"><span style="color: red">CommandArgument</span><span style="color: blue">=&#8217;</span><span style="background: #ffee62">&lt;%</span># Eval(&quot;id&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;</span> <span style="color: red">CommandName</span><span style="color: blue">=&quot;Select&quot;</span> <span style="color: red">ForeColor</span><span style="color: blue">=&quot;black&quot;</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TemplateField</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TemplateField</span> <span style="color: red">ShowHeader</span><span style="color: blue">=&quot;True&quot;</span> <span style="color: red">HeaderText</span><span style="color: blue">=&quot;Assign To New Content By Default&quot;</span> <span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ImageButton</span> <span style="color: red">ID</span><span style="color: blue">=&quot;LinkButtonToggleDefaultChecked&quot;</span> <span style="color: red">SkinID</span><span style="color: blue">=&#8217;iconCheckedEnabled&#8217;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">BackColor</span><span style="color: blue">=&quot;white&quot;</span> <span style="color: red">CausesValidation</span><span style="color: blue">=&quot;False&quot;</span></p>
<p style="margin: 0px"><span style="color: red">visible</span><span style="color: blue">=&#8217;</span><span style="background: #ffee62">&lt;%</span># (bool) Eval(&quot;Defaultnewcontent&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;</span></p>
<p style="margin: 0px"><span style="color: red">CommandArgument</span><span style="color: blue">=&#8217;</span><span style="background: #ffee62">&lt;%</span># Eval(&quot;id&quot;) + &quot;;&quot; + Eval(&quot;Approved&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;</span> <span style="color: red">CommandName</span><span style="color: blue">=&quot;ToggleDefault&quot;</span> <span style="color: red">ForeColor</span><span style="color: blue">=&quot;black&quot;</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ImageButton</span> <span style="color: red">ID</span><span style="color: blue">=&quot;LinkButtonToggleDefaultUnChecked&quot;</span> <span style="color: red">SkinID</span><span style="color: blue">=&quot;iconUnCheckedEnabled&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span> <span style="color: red">BackColor</span><span style="color: blue">=&quot;white&quot;</span> <span style="color: red">CausesValidation</span><span style="color: blue">=&quot;False&quot;</span></p>
<p style="margin: 0px"><span style="color: red">visible</span><span style="color: blue">=&#8217;</span><span style="background: #ffee62">&lt;%</span># !(bool) Eval(&quot;Approved&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;</span></p>
<p style="margin: 0px"><span style="color: red">CommandArgument</span><span style="color: blue">=&#8217;</span><span style="background: #ffee62">&lt;%</span># Eval(&quot;id&quot;) + &quot;;&quot; + Eval(&quot;Approved&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;</span> <span style="color: red">CommandName</span><span style="color: blue">=&quot;ToggleDefault&quot;</span> <span style="color: red">ForeColor</span><span style="color: blue">=&quot;black&quot;</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TemplateField</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField</span> <span style="color: red">DataField</span><span style="color: blue">=&quot;Name&quot;</span> <span style="color: red">HeaderText</span><span style="color: blue">=&quot;Name&quot;</span> <span style="color: red">SortExpression</span><span style="color: blue">=&quot;Name&quot;</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">Columns</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">GridView</span><span style="color: blue">&gt;</span></p>
</p></div>
<p>Then, when you finally run it, the gridview looks something like this.</p>
<p><a title="gridviewWithSKins.jpg" href="http://peterkellner.net/wp/wp-content/uploads/2007/11/gridviewwithskins.jpg" rel="lightbox"><img id="urn:zoundry:jid:gridviewWithSKins.jpg" title="gridviewWithSKins.jpg" border="0" alt="gridviewWithSKins.jpg" src="http://peterkellner.net/wp/wp-content/uploads/2007/11/gridviewwithskins-tn.jpg" width="200" height="157" /></a></p>
<p>Notice no codebehind was necessary for this trick! Good luck and hope this save you some time.</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt"></div>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/11/23/gridviewskincheckbox/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using Using in c# ado.net business classes used with ObjectDataSource in ASP.NET 2.0</title>
		<link>http://peterkellner.net/2007/10/29/usingusinghowto/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=usingusinghowto</link>
		<comments>http://peterkellner.net/2007/10/29/usingusinghowto/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 01:28:57 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/10/29/usingusinghowto/</guid>
		<description><![CDATA[A short post and example on how to use the C# syntax Using.  The example is for an ado.net business object that can be used with an ObjectDataSource.  This saves you the trouble of disposing of your objects properly, as well as doing it at the right place.]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve been preaching for a long time that it&#8217;s best to use the Using pattern when working with anything that implements IDisposable.&#160; That way, you don&#8217;t have to worry about calling Dispose, or calling Close.&#160; The framework will just do it for you.&#160; I&#8217;ve answered this question on the forums several times so I thought I&#8217;d past some code I&#8217;m doing right now for simple ado.net stuff.&#160; It&#8217;s actually code that is inside a business object that I hook up to an ObjectDataSource in asp.net 2.0. </p>
<p>The code is posted below.&#160; I think you&#8217;ll get the idea.</p>
<p> <span id="more-83"></span>
<p>[<span style="color: #2b91af">DataObjectMethod</span>(<span style="color: #2b91af">DataObjectMethodType</span>.Select, <span style="color: blue">false</span>)]</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: blue">public</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt; GetByPrimaryKey(<span style="color: blue">int</span> id)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: blue">string</span> sqlWhere = <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot; WHERE id={0} &quot;</span>, id);</p>
<p style="margin: 0px"><span style="color: blue">return</span> GetByRawSQL(<span style="color: blue">string</span>.Empty, sqlWhere);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: blue">private</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt; GetByRawSQL(<span style="color: blue">string</span> sortData, <span style="color: blue">string</span> sqlWhereClause)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: blue">string</span> sqlBaseString = <span style="color: #a31515">&quot;SELECT ContentTypeId,Description,SortOrder,Id FROM Category &quot;</span>;</p>
<p style="margin: 0px"><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt; DataTemplateODSList = <span style="color: blue">new</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt;();</p>
<p style="margin: 0px"><span style="color: blue">using</span> (<span style="color: #2b91af">SqlConnection</span> conn = <span style="color: blue">new</span> <span style="color: #2b91af">SqlConnection</span>(connectionString))</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; conn.Open();</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">if</span> (!<span style="color: #2b91af">String</span>.IsNullOrEmpty(sqlWhereClause))</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlBaseString += sqlWhereClause;</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">using</span> (<span style="color: #2b91af">SqlCommand</span> cmd = <span style="color: blue">new</span> <span style="color: #2b91af">SqlCommand</span>(sqlBaseString, conn))</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">using</span> (<span style="color: #2b91af">SqlDataReader</span> reader = cmd.ExecuteReader())</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">try</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">while</span> (reader.Read())</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> contenttypeid = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">string</span> description = reader.IsDBNull(1) ? <span style="color: #a31515">&quot;&quot;</span> : reader.GetString(1);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> sortorder = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">DataObjectCategory</span> td = <span style="color: blue">new</span> <span style="color: #2b91af">DataObjectCategory</span>(contenttypeid,</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; description, sortorder, id);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DataTemplateODSList.Add(td);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">catch</span> (<span style="color: #2b91af">Exception</span> ee)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">ApplicationException</span>(ee.ToString());</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">}</p>
</p></div>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/10/29/usingusinghowto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Set the Default Value of a DropDownList in an ASP.NET Page</title>
		<link>http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dropdownlistdefaultsetting</link>
		<comments>http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 17:44:13 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Membership]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/</guid>
		<description><![CDATA[<p> This article shows how to set the default Value of a DropDownList Control when using asp.net 2.0.  It uses the DataBound event to do it.  A full page example which can be cut and paste is included</p>]]></description>
			<content:encoded><![CDATA[<h2>(Using Membership ObjectDataSource From MSDN Article)</h2>
<p>I&#8217;m doing a project where I have lots of DropDownList&#8217;s on a page and want a simple way to set the initial values based on some known value.&#160; The DropDownLists are retrieved using ObjectDataSource but I don&#8217;t want the first value displayed.&#160; I wrestled some with how to do this using page_load or page_prerender but didn&#8217;t come up with good solutions.&#160; I did finally    <br />decide that programming the databound event of the dropdownlist was probably the best way to go. </p>
<p>The solution is pasted below.&#160; The MembershipUtilities.MembershipODS c# code can be downloaded from MSDN or on my web site at the following location.&#160; </p>
<p> <span id="more-80"></span>
<p><a href="http://peterkellner.net/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/">http://peterkellner.net/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/</a>.</p>
<p> <!-- code formatted by http://manoli.net/csharpformat/ --><br />
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}</p>
<p>.csharpcode pre { margin: 0em; }</p>
<p>.csharpcode .rem { color: #008000; }</p>
<p>.csharpcode .kwrd { color: #0000ff; }</p>
<p>.csharpcode .str { color: #006080; }</p>
<p>.csharpcode .op { color: #0000c0; }</p>
<p>.csharpcode .preproc { color: #cc6633; }</p>
<p>.csharpcode .asp { background-color: #ffff00; }</p>
<p>.csharpcode .html { color: #800000; }</p>
<p>.csharpcode .attr { color: #ff0000; }</p>
<p>.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}</p>
<p>.csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode"><span class="asp">&lt;%@ Page Language=”C#” %&gt;</span>
<span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> “<span class="attr">-</span>//<span class="attr">W3C</span>//<span class="attr">DTD</span> <span class="attr">XHTML</span> <span class="attr">1</span>.<span class="attr">0</span> <span class="attr">Transitional</span>//<span class="attr">EN</span>”

  “<span class="attr">http:</span>//<span class="attr">www</span>.<span class="attr">w3</span>.<span class="attr">org</span>/<span class="attr">TR</span>/<span class="attr">xhtml1</span>/<span class="attr">DTD</span>/<span class="attr">xhtml1-transitional</span>.<span class="attr">dtd</span>”<span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">protected</span> <span class="kwrd">void</span> DropDownListUser_DataBound(<span class="kwrd">object</span> sender, EventArgs e)

    {
        DropDownListUser.SelectedIndex =
          DropDownListUser.Items.IndexOf
          (DropDownListUser.Items.FindByValue(Context.User.Identity.Name));
    }
<span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span>=”<span class="attr">http:</span>//<span class="attr">www</span>.<span class="attr">w3</span>.<span class="attr">org</span>/<span class="attr">1999</span>/<span class="attr">xhtml</span>” <span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>DropDownList Initialize<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span>=”<span class="attr">form1</span>″ <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:DropDownList</span> <span class="attr">ID</span>=”<span class="attr">DropDownListUser</span>” <span class="attr">runat</span>=”<span class="attr">server</span>”
          <span class="attr">DataSourceID</span>=”<span class="attr">ObjectDataSourceUser</span>”
          <span class="attr">DataTextField</span>=”<span class="attr">UserName</span>” <span class="attr">DataValueField</span>=”<span class="attr">UserName</span>”
          <span class="attr">OnDataBound</span>=”<span class="attr">DropDownListUser_DataBound</span>”<span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">asp:DropDownList</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:ObjectDataSource</span> <span class="attr">ID</span>=”<span class="attr">ObjectDataSourceUser</span>” <span class="attr">runat</span>=”<span class="attr">server</span>”
          <span class="attr">SelectMethod</span>=”<span class="attr">GetMembers</span>”
          <span class="attr">TypeName</span>=”<span class="attr">MembershipUtilities</span>.<span class="attr">MembershipUserODS</span>”<span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">SelectParameters</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:Parameter</span> <span class="attr">Name</span>=”<span class="attr">sortData</span>” <span class="attr">Type</span>=”<span class="attr">String</span>” <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">SelectParameters</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">asp:ObjectDataSource</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Speaking Saturday 9/15 4PM at Silverlight DevCamp, San Francisco</title>
		<link>http://peterkellner.net/2007/09/13/silverlightbarcamp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlightbarcamp</link>
		<comments>http://peterkellner.net/2007/09/13/silverlightbarcamp/#comments</comments>
		<pubDate>Fri, 14 Sep 2007 05:24:19 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/09/13/silverlightbarcamp/</guid>
		<description><![CDATA[<br />
<p><strong>Topic:  Building animation into "Community Media Browser" for Leverage Software with Silverlight Alpha 1.1</strong></p>
<br />
<a href="http://barcamp.org/SilverlightDevCampSF">
<img src="http://peterkellner.net/wp/Images/silverlightDevCamp_sf_t.png" class="style1" /></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Topic: Building animation into &quot;Community Media Browser&quot; for Leverage Software with Silverlight Alpha 1.1</strong></p>
<p><a href="http://barcamp.org/SilverlightDevCampSF"></a></p>
<p><img class="style1" src="http://peterkellner.net/wp/Images/silverlightDevCamp_sf.png" /></p>
<p> <span id="more-77"></span>
<p>SilverlightDevCampSF is an upcoming gathering, inspired by <a href="http://www.barcamp.org">BarCamp</a>, to build <a href="http://silverlight.net">Silverlight</a> applications, It&#8217;s organized by volunteers &amp; Silverlight enthusiasts, with attendance free to all. At this event, I will be presenting a 30 minute presentation on how to build animation into a Silverlight application. I&#8217;ll talk about the implementation details of building the picture slider used in the <a href="http://labs.leveragesoftware.com/silverlight.html">Community Media Browser</a> preview hosted at     <br /><a href="http://labs.leveragesoftware.com/gallery.html">     <br />http://labs.leveragesoftware.com/gallery.html</a> .&#160; In this informal talk I&#8217;ll discuss how LoadXaml() was critical to this process as well as other tricks.&#160; Because the picture slider is running from a live web feed, there is no way to know ahead of time how many picture we may have to scroll so clipping type solutions just don&#8217;t make sense.&#160; Time permitting, we&#8217;ll talk about other issues involved in building this application and of course take     <br />questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/09/13/silverlightbarcamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silicon Valley Code Camp Integrates the DevExpress Cloud Control for Sessions</title>
		<link>http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cloudcontrolforcodecamp</link>
		<comments>http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 19:11:58 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Atlas/AJAX]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[ObjectDataSource]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/</guid>
		<description><![CDATA[Using the DevExpress CloudControl in the ASP.NET 2.0 Silicon Valley Code Camp's web site was easy.  In this short post, you'll hear about the details and see some code.]]></description>
			<content:encoded><![CDATA[<p>Recently, is seems that many web sites and blogs are starting to use a navigation technique where you have multiple hyperlinks grouped in a box, with size, color, or brightness giving some meaning.&#160; I like this very much and have been on the lookout for a while for a control to do this in ASP.NET.&#160; Turns out, DevExpress has one!&#160; It&#8217;s called the CloudControl and you can read more about it at the following URL.</p>
<p> <span id="more-74"></span>
<p>&#160;<a href="http://www.devexpress.com/Products/NET/WebForms/ASPxCloudControl/Index.xml">http://www.devexpress.com/Products/NET/WebForms/ASPxCloudControl/Index.xml</a></p>
<p>So, now, where to use it?&#160; Code Camp of course!&#160; Now, if you browse to the Sessions listing, you&#8217;ll see the DevExpress Cloud Control in use.</p>
<p><img alt="Silicon Valley Code Camp Cloud Control" src="http://peterkellner.net/wp/Images/misc/cloudcontrol.jpg" /></p>
<p>You can see this control in action at our web site here:&#160; <br /><a href="http://www.siliconvalley-codecamp.com/Sessions.aspx">     <br />http://www.siliconvalley-codecamp.com/Sessions.aspx</a></p>
<p>My experience with using this control was great!&#160; Easy to setup.&#160; Below is all the code I needed on my asp page to make it happen.</p>
<p>&#160;<!--<br />
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red0\green0\blue0;\red255\green0\blue0;}??\fs20 \cf1 &lt;\cf3 dxcc\cf1 :\cf3 ASPxCloudControl\cf0  \cf5 ID\cf1 =&#8221;ASPxCloudControl1&#8243;\cf0  \cf5 runat\cf1 =&#8221;server&#8221;\cf0  \par ??           \cf5 DataSourceID\cf1 =&#8221;ObjectDataSourceCloudControl&#8221;\cf0  \cf5 ShowValues\cf1 =&#8221;True&#8221;\cf0  \par ??           \cf5 HorizontalAlign\cf1 =&#8221;NotSet&#8221;\cf0  \cf5 TextField\cf1 =&#8221;TagName&#8221;\cf0  \cf5 ValueField\cf1 =&#8221;TagCount&#8221;\cf0  \par ??           \cf5 NavigateUrlField\cf1 =&#8221;TagId&#8221;\cf0  \par ??           \cf5 NavigateUrlFormatString\cf1 =&#8221;Sessions.aspx?sortby=title&amp;by=category&amp;tag=\{0\}&#8221;\cf0  \par ??           \cf5 ToolTip\cf1 =&#8221;CloudControl Provided From DevExpress&#8221;&gt;\par ??\cf0                 \cf1 &lt;\cf3 RankProperties\cf1 &gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                 \cf1 &lt;/\cf3 RankProperties\cf1 &gt;\par ??\cf0         \cf1 &lt;/\cf3 dxcc\cf1 :\cf3 ASPxCloudControl\cf1 &gt;\par ??\cf0         \cf1 &lt;\cf3 asp\cf1 :\cf3 ObjectDataSource\cf0  \cf5 ID\cf1 =&#8221;ObjectDataSourceCloudControl&#8221;\cf0  \cf5 runat\cf1 =&#8221;server&#8221;\cf0  \par ??            \cf5 SelectMethod\cf1 =&#8221;GetAllTags&#8221;\cf0  \cf5 TypeName\cf1 =&#8221;CodeCampSV.SessionTagsODS&#8221;&gt;\par ??\cf0         \cf1 &lt;/\cf3 asp\cf1 :\cf3 ObjectDataSource\cf1 &gt;}<br />
&#8211;></p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 52</span>&#160;<span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">ASPxCloudControl</span> <span style="color: red">ID</span><span style="color: blue">=&quot;ASPxCloudControl1&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 53</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">DataSourceID</span><span style="color: blue">=&quot;ObjectDataSourceCloudControl&quot;</span> <span style="color: red">ShowValues</span><span style="color: blue">=&quot;True&quot;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 54</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">HorizontalAlign</span><span style="color: blue">=&quot;NotSet&quot;</span> <span style="color: red">TextField</span><span style="color: blue">=&quot;TagName&quot;</span> <span style="color: red">ValueField</span><span style="color: blue">=&quot;TagCount&quot;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 55</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">NavigateUrlField</span><span style="color: blue">=&quot;TagId&quot;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 56</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">NavigateUrlFormatString</span><span style="color: blue">=&quot;Sessions.aspx?sortby=title&amp;by=category&amp;tag={0}&quot;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 57</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">ToolTip</span><span style="color: blue">=&quot;CloudControl Provided From DevExpress&quot;&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 58</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">RankProperties</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 59</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 60</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 61</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 62</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 63</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 64</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 65</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 66</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;/</span><span style="color: #a31515">RankProperties</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 67</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;/</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">ASPxCloudControl</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 68</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ObjectDataSource</span> <span style="color: red">ID</span><span style="color: blue">=&quot;ObjectDataSourceCloudControl&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 69</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">SelectMethod</span><span style="color: blue">=&quot;GetAllTags&quot;</span> <span style="color: red">TypeName</span><span style="color: blue">=&quot;CodeCampSV.SessionTagsODS&quot;&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 70</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ObjectDataSource</span><span style="color: blue">&gt;</span></p>
</p></div>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">This is my first trip into the Developer Express toolbox and so far, I&#8217;m very impressed!</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Logging From an ASP.NET 2.0 Application to a Local File</title>
		<link>http://peterkellner.net/2007/08/12/aspnetsimplelogging/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=aspnetsimplelogging</link>
		<comments>http://peterkellner.net/2007/08/12/aspnetsimplelogging/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 00:54:36 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/08/12/aspnetsimplelogging/</guid>
		<description><![CDATA[<br />In this article, a very simple method is demonstrated for logging text data in an asp.net 2.0 application.  It's safe, reliable, but not very elegant.  Just what you need when you want to crank something out for testing or proof of concept.  It uses StreamWriter and MapPath to get it's job done.]]></description>
			<content:encoded><![CDATA[<p><strong>(User MapPath and FileStream Together)</strong></p>
<p>A very common scenario we often run into is we need to log some information to a local text file on the web server.&#160; We know we can use all the health monitoring capabilities built in to asp.net for reasons like performance,   <br />standards, best practices, etc., but sometimes, you just want to log something right now and you don&#8217;t want to spend a lot of time.</p>
<p> <span id="more-72"></span>
<p>So, Here is a very very simple version that does that and is 100% reliable.&#160; Basically, say you wanted to simply log the useragent from a request to a file called ~/App_Data/UserAgents.txt.&#160; Here is some simple code to do that.</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 1</span>&#160;<span style="color: blue">using</span> System;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 2</span>&#160;<span style="color: blue">using</span> System.Data;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 3</span>&#160;<span style="color: blue">using</span> System.Configuration;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 4</span>&#160;<span style="color: blue">using</span> System.Collections;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 5</span>&#160;<span style="color: blue">using</span> System.Web;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 6</span>&#160;<span style="color: blue">using</span> System.Web.Security;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 7</span>&#160;<span style="color: blue">using</span> System.Web.UI;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 8</span>&#160;<span style="color: blue">using</span> System.Web.UI.WebControls;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 9</span>&#160;<span style="color: blue">using</span> System.Web.UI.WebControls.WebParts;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 10</span>&#160;<span style="color: blue">using</span> System.Web.UI.HtmlControls;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 11</span>&#160;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 12</span>&#160;<span style="color: blue">public</span> <span style="color: blue">partial</span> <span style="color: blue">class</span> <span style="color: #2b91af">Default2</span> : System.Web.UI.<span style="color: #2b91af">Page</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 13</span> {</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 14</span>&#160;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 15</span>&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: #2b91af">Object</span> synchronizeVariable = <span style="color: #a31515">&quot;locking&quot;</span>;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 16</span>&#160;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 17</span>&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">void</span> Page_Load(<span style="color: blue">object</span> sender, <span style="color: #2b91af">EventArgs</span> e)</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 18</span>&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 19</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">String</span> fileName = Context.Server.MapPath(<span style="color: #a31515">&quot;~&quot;</span>) +</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 20</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #a31515">&quot;\\App_Data\\UserAgents.txt&quot;</span>;</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 21</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">lock</span> (synchronizeVariable)</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 22</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 23</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; StreamWriter sw = <span style="color: blue">new</span> StreamWriter(fileName, <span style="color: blue">true</span>);</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 24</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sw.WriteLine(<span style="color: #2b91af">DateTime</span>.Now);</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 25</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sw.WriteLine(Request.UserAgent);</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 26</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sw.Close();</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 27</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 28</span>&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 29</span> }</p>
</p></div>
<p>Just to be safe, we added a lock around the file write code.&#160; This way, if two processes come in at the same time, they will both write out correctly. Again, this is very crude, not very efficient or elegant, but very clean and   <br />reliable.&#160; Just don&#8217;t mention you got it from me!</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/08/12/aspnetsimplelogging/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Display Images with the Silverlight Downloader in Alpha 1.1</title>
		<link>http://peterkellner.net/2007/07/03/silverlightdownloader/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlightdownloader</link>
		<comments>http://peterkellner.net/2007/07/03/silverlightdownloader/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 04:38:34 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Page Handlers]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/07/03/silverlightdownloader/</guid>
		<description><![CDATA[<br /><p>This article gives you a way to download images from remote servers on different domains using the downloader object of Silverlight.  Without this, you can not easily keep track of when images are downloaded to your Silverlight Application and deal with that event.  You simply can set the source tag and the image arrives when it arrives.</p>]]></description>
			<content:encoded><![CDATA[<p><strong>From Non-Local Servers Asynchronously</strong></p>
<p>This issue has come up several times for me.&#160; That is, you have an image&#160; url you want to display in your silverlight .net 1.1 application that comes from&#160; some foreign server.&#160; That is, you want this to work:&#160; (and of course    <br />it does not).</p>
<h2>The Problem</h2>
<p><img alt="does not work" src="http://peterkellner.net/misc/downloader1.jpg" /></p>
<p> <span id="more-67"></span>
<p>Even though, you can do this:</p>
<p><img alt="does not work" src="http://peterkellner.net/misc/downloader2a.jpg" /></p>
<p>There seems to be a subtle difference having to do with cross domain security&#160; that I just don&#8217;t get but since it&#8217;s there, we have to deal with it.</p>
<h2>The Solution</h2>
<p>So first, why do you even care.&#160; Why not just do the one that works?&#160; Well, the answer is that you want to be able to deal with what happens while an image is being downloaded.&#160; My particular problem has to do with what happens when you bring up a picture in a modal dialog type thing.&#160; That is, you click on a small thumbnail, and a larger ones comes up.&#160; In my case, I&#8217;m getting the image url from a web service so I don&#8217;t have the luxury of opening it locally.&#160; I have to use a foreign (remote) url.&#160; And, the reason I don&#8217;t want to open it by simply setting the source tag is that I&#8217;m    <br />reusing a control.&#160; This means that I&#8217;m simply hiding it and unhiding it. If I just set the source and unhide it, the wrong image comes up.&#160; That is, the one from the previous request. Then, a few seconds later, the correct image     <br />comes up.&#160; Bad.</p>
<p>We really want to use the Downloader object.&#160; A very cool control, but not if it doesn&#8217;t work cross domain IMHO.</p>
<p>The work around for this is to write a http handler that runs in your local asp.net project that you pass the url you want to display. Then, that web service turns around, calls the cross domain server, gets the image and returns it to your Downloader object.&#160; Simple in concept, but the devil is in the details.&#160; How, for example to you pass a url (that may include all kinds of stuff like &amp;&#8217;s to a local web service.&#160; The answer is encode it!&#160; Then decode it at the web service.&#160; I&#8217;m sure you all can whip that up quickly, but since I did already, why bother.&#160; I&#8217;m going to paste the code below with brief explanations to help.&#160; Here goes:</p>
<h3>The Silverlight UserControl That Calls the web service</h3>
<p>The way I did the code in the silverlight control is to encode the real URL I want.&#160; That is the one cross domain.&#160; I think build a URL that calls my local web service passing the parameter encoded as a base64 value as one of    <br />the url parameters.&#160; I&#8217;m using a property in my usercontrol to set this value just because that&#8217;s kind of convenient.&#160; Here is what the code looks like:</p>
<p><img alt="does not work" src="http://peterkellner.net/misc/downloader3.jpg" /></p>
<p>Just to give you a hint of what the might look like, in my case, this is what it is:</p>
<p><a href="http://localhost:49803/WebService/DisplayImage.ashx?URL=aHR0cDov...NDE0NzU2LkpQRw==&amp;Width=400">     <br />http://localhost:49803/WebService/DisplayImage.ashx?URL=aHR0cDov&#8230;NDE0NzU2LkpQRw==&amp;Width=400</a></p>
<p>(I put a bunch of &#8230;&#8217;s in the middle, but it was longer than that originally)</p>
<p>Silverlight is kind of limited on conversion functions so I had to write this little one called EncodeTo64 which is pasted below.&#160; I&#8217;m sure there are better ways to do it, but this one works.</p>
<p><img alt="does not work" src="http://peterkellner.net/misc/downloader5.jpg" /></p>
<p>And, don&#8217;t forget that you need to have the completed event code in your silverlight side to handle setting the source tag when the image is fully downloaded.&#160; Here is that function.</p>
<p><img alt="does not work" src="http://peterkellner.net/misc/downloader6a.jpg" /></p>
<h3>The Http Handler (DisplayImage.ashx file)</h3>
<p>To make all this come to live, you need an http handler that will make the call to the cross domain server.&#160; Below is that code.&#160; I added an extra parameter for width so that if you know the image you need is smaller than the one across the internet, you can just get downloaded what you need.&#160; Here is the code for the handler:</p>
<p><img alt="does not work" src="http://peterkellner.net/misc/downloader7.jpg" /></p>
<p>&#160;</p>
<h2>Conclusion</h2>
<p>I&#8217;m guessing that this problem will go away in the next alpha or beta release of Silverlight .net.&#160; In the mean time, this works very well for me and hopefully will for you also.&#160; I don&#8217;t have this in a good sample application and really just wanted to get it posted because I know others were having the same problems.&#160; If someone goes through and makes a good demo of this, please post a comment with the code for others to download.</p>
<p>Thanks for reading, and best of luck with your Silverlight Development!</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/07/03/silverlightdownloader/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Microsoft ASP.NET Member/Role Management with IIS (VB Version)</title>
		<link>http://peterkellner.net/2007/02/15/membershipodsvb/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=membershipodsvb</link>
		<comments>http://peterkellner.net/2007/02/15/membershipodsvb/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 20:08:16 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/02/15/membershipodsvb/</guid>
		<description><![CDATA[<p>Back in January of 2006, I published on
<a href="http://peterkellner.net/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/">
MSDN an article and source code for managing ASP.NET 2.0 Membership users with
an ObjectDataSource.</a>&#160; Since I&#39;m not much of a VB person, I only
published them in c#.&#160; since then, I&#39;ve had hundreds of requests for this
code in VB.&#160; Until now, I&#39;ve had to send an excuse for not having it.&#160;
Now, thanks to Dave at <a href="http://www.tangiblesoftwaresolutions.com/">
Tangible Solutions Software</a>,
we now have a VB version.</p>]]></description>
			<content:encoded><![CDATA[<h2>The Visual Basic Version of the Objects!</h2>
<p>Back in January of 2006, I published on <a href="http://peterkellner.net/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/">MSDN an article and source code for managing ASP.NET 2.0 Membership users with an ObjectDataSource.</a>&#160; Since I&#8217;m not much of a VB person, I only published them in c#.&#160; since then, I&#8217;ve had hundreds of requests for this code in VB.&#160; Until now, I&#8217;ve had to send an excuse for not having it. Now, thanks to Dave at&#160; <a href="http://www.tangiblesoftwaresolutions.com/">Tangible Solutions Software</a>, we now have a VB version.&#160; Dave converted it with there conversion software called <em>Instant VB</em>.</p>
<p class="style1">The following zip file includes these VB objects along with a very simple aspx page in VB.&#160; It does not include any more complete examples of using the objects because the code associated with the aspx pages I wrote is all in c#.&#160; If anyone wants to convert the other pages, I&#8217;d be happy to post those also.</p>
<p class="style1">Thanks Dave and Thanks Tangible Solutions!    <br /><a href="http://peterkellner.net/DownLoads/MembershipEditorVB.zip">     <br />http://peterkellner.net/DownLoads/MembershipEditorVB.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/02/15/membershipodsvb/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 32/37 queries in 0.012 seconds using disk: basic
Content Delivery Network via Amazon Web Services: S3: PetersBlogCDN.s3.amazonaws.com

Served from: peterkellner.net @ 2012-05-22 09:33:01 -->
