<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Intrepid Studios, Inc. Blog</title>
    <image>
      <url>http://www.intrepidstudios.com/lib/img/logo-white-bg.gif</url>
      <title>Intrepid Studios, Inc.</title>
      <link>http://www.intrepidstudios.com/</link>
    </image>
    <link>http://www.intrepidstudios.com/</link>
    <description>Articles, tips &amp; tricks, news, and more from Intrepid Studios. Topics include ASP.NET, jQuery, web design, and other web topics.</description>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/IntrepidStudios" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
      <title>Power Tip: Convert a string to an array of Integers</title>
      <description>&lt;p&gt;Here are two extension methods that can convert a string (delimited by anything of your choosing) into an array of integers. Successfully handles any non-Integer data smoothly as well.&lt;/p&gt;  &lt;pre class="brush: vb;"&gt;Public Module TypeExtensions

    &amp;lt;Extension()&amp;gt; _
    Public Function ToArrayOfInts(ByVal str() As String) As IEnumerable(Of Integer)
        Dim intRef As Integer
        Return str _
        .Where(Function(s) Not String.IsNullOrEmpty(s) AndAlso Integer.TryParse(s, intRef)) _
        .Select(Function(s) Integer.Parse(s))
    End Function
    
    &amp;lt;Extension()&amp;gt; _
    Public Function ToArrayOfInts(ByVal str As String, ByVal delimeter As String) As IEnumerable(Of Integer)
        Return str.Split(delimeter).ToArrayOfInts()
    End Function

End Module&lt;/pre&gt;

&lt;p&gt;You can use it like this:&lt;/p&gt;

&lt;pre class="brush: vb; gutter: false; toolbar: false;"&gt;foo.Text = &amp;quot;093,s,44g,sj38,87,6&amp;quot;.ToArrayOfInts(&amp;quot;,&amp;quot;).Count().ToString()&lt;/pre&gt;</description>
      <pubDate>Tue, 21 Jul 2009 18:34:33 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-75</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/WYZiz0Yy52Q/power-tip-convert-a-string-to-an-array-of-int.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/7/21/power-tip-convert-a-string-to-an-array-of-int.aspx</feedburner:origLink></item>
    <item>
      <title>Using GUIDs in LinqDataSource Controls</title>
      <description>&lt;p&gt;This was a small tip I learned searching across the web. In order to use a Guid DataType (from the DB) in a Where attribute on a LinqDataSource you have to do it like this:&lt;/p&gt;  &lt;pre class="brush: xml;"&gt;&amp;lt;asp:LinqDataSource id=&amp;quot;MyDS&amp;quot;
    Where=&amp;quot;MyGuidColumn.ToString() == @StringGuid&amp;quot;
    ...&amp;gt;
    &amp;lt;WhereParameters&amp;gt;
        &amp;lt;asp:QueryStringParameter QueryStringField=&amp;quot;Id&amp;quot;
            Type=&amp;quot;String&amp;quot; Name=&amp;quot;StringGuid&amp;quot; /&amp;gt;
    &amp;lt;/WhereParameters&amp;gt;
&amp;lt;/asp:LinqDataSource&amp;gt;&lt;/pre&gt;

&lt;p&gt;If you use a Session or some other parameter that returns the Guid itself, you have to have Type=&amp;quot;Object&amp;quot; in your parameter, like in my project:&lt;/p&gt;

&lt;pre class="brush: xml; gutter: false; toolbar: false;"&gt;&amp;lt;asp:SessionParameter SessionField=&amp;quot;ColumnId&amp;quot; Type=&amp;quot;Object&amp;quot; Name=&amp;quot;ColumnId&amp;quot; /&amp;gt;&lt;/pre&gt;</description>
      <pubDate>Thu, 16 Jul 2009 03:47:07 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-74</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/tjN6an9wTH4/using-guids-in-linqdatasource-controls.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/7/16/using-guids-in-linqdatasource-controls.aspx</feedburner:origLink></item>
    <item>
      <title>Maintaining Checked State On Radio/Checkbox Controls On Post Back</title>
      <description>&lt;p&gt;I had a unique problem today. Here's the scenario:&lt;/p&gt;  &lt;p&gt;You have a ListView that &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc500643.aspx" target="_blank"&gt;dynamically loads different ItemTemplates&lt;/a&gt; depending on a specific criteria (in my case, a category). You load this user control template into the ItemTemplate and create some radio and checkbox buttons. If you set GroupName on the controls to a group name, .NET &lt;strong&gt;will not&lt;/strong&gt; associate all the different buttons across the templates because they have different naming containers.&lt;/p&gt;  &lt;p&gt;I have a dynamically generated form where the user selects from a multitude of options (i.e. each ListViewItemTemplate contains an input control), so this default behavior doesn't work so well. Some might say to scrap the custom ListView and create a composite control that inserts different controls depending on a parameter but then you get into a lot of databinding issues and viewstate tracking issues. I wanted to avoid all of that. &lt;strong&gt;Note:&lt;/strong&gt; If someone has a good way of doing this, please let me know!&lt;/p&gt;  &lt;p&gt;Here's what I came up with. It derives from a RadioButton (but a CheckBox would work too) and adds two custom properties, Name and Value, allowing you to specify the value of the input and name of the input. It overrides the Render event and outputs custom HTML depending on if the button was checked on PostBack. It works great!&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre class="brush: vb; collapse: true;"&gt;Public Class CustomRadioButton
    Inherits RadioButton

    Public Property Name() As String
        Get
            Dim o As Object = ViewState(&amp;quot;Name&amp;quot;)

            Return If(o Is Nothing, String.Empty, CStr(o))
        End Get
        Set(ByVal value As String)
            ViewState(&amp;quot;Name&amp;quot;) = value
        End Set
    End Property

    Public Property Value() As String
        Get
            Dim o As Object = ViewState(&amp;quot;Value&amp;quot;)

            Return If(o Is Nothing, String.Empty, CStr(o))
        End Get
        Set(ByVal value As String)
            ViewState(&amp;quot;Value&amp;quot;) = value
        End Set
    End Property

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
        If Page.IsPostBack Then
            writer.Write(String.Format(&amp;quot;&amp;lt;input id='{0}' type='radio' name='{1}' value='{2}' {3} /&amp;gt;&amp;quot;, ClientID, Name, Value, If(Page.Request.Form(Name) = Value, &amp;quot;checked='checked'&amp;quot;, String.Empty)))
        Else
            writer.Write(String.Format(&amp;quot;&amp;lt;input id='{0}' type='radio' name='{1}' value='{2}' /&amp;gt;&amp;quot;, ClientID, Name, Value))
        End If
    End Sub
End Class&lt;/pre&gt;

&lt;p&gt;And in the user control:&lt;/p&gt;

&lt;pre class="brush: xml;"&gt;&amp;lt;MyControls:CustomRadioButton ID=&amp;quot;radButton&amp;quot; 
    Name='&amp;lt;%#String.Format(&amp;quot;rad_group_{0}&amp;quot;, Eval(&amp;quot;MyGroupId&amp;quot;).ToString()) %&amp;gt;' 
    Value='&amp;lt;%# Eval(&amp;quot;MyValue&amp;quot;) %&amp;gt;' 
    runat=&amp;quot;server&amp;quot; /&amp;gt;

&amp;lt;%-- You can also make it static text. --%&amp;gt;&lt;/pre&gt;</description>
      <pubDate>Thu, 16 Jul 2009 03:32:22 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-73</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/nrgckQrxxgU/maintaining-checked-state-on-radiocheckbox-co.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/7/16/maintaining-checked-state-on-radiocheckbox-co.aspx</feedburner:origLink></item>
    <item>
      <title>How To: Use a ListView to Make People Read a Statement Before Filling Out Your Form</title>
      <description>&lt;p&gt;I use a ListView to display a form based off of a data model that people fill out. I know that ListViews are meant for lists but I like that you can databind it to a source so you don't have to do any code behind. In my case, I just need values from a custom control within the ListView.&lt;/p&gt;  &lt;p&gt;That said, I will assume you're in a similar scenario. I needed to display a privacy notice before someone fills out a form and I knew I could just create two panels and show/hide them, etc. or two pages. However, I usually like exploring different ways of doing things.&lt;/p&gt;  &lt;p&gt;All you have to do is make use of some clever manipulation of the Templates:&lt;/p&gt;  &lt;pre class="brush: xml;"&gt;&amp;lt;asp:listview id=&amp;quot;MyListView&amp;quot; runat=&amp;quot;server&amp;quot; DataSourceID=&amp;quot;SomeDataSource&amp;quot; DataKeyNames=&amp;quot;Id&amp;quot;&amp;gt;
    &amp;lt;LayoutTemplate&amp;gt;                                  
        &amp;lt;asp:placeholder id=&amp;quot;itemPlaceholder&amp;quot; runat=&amp;quot;server&amp;quot; /&amp;gt;
    &amp;lt;/LayoutTemplate&amp;gt;
    &amp;lt;ItemTemplate&amp;gt;
        &amp;lt;h1&amp;gt;Privacy Notice&amp;lt;/h1&amp;gt;
        
        &amp;lt;p&amp;gt;Some Text&amp;lt;/p&amp;gt;
        
        &amp;lt;%-- Notice the Select command --%&amp;gt;
        &amp;lt;asp:button id=&amp;quot;btnContinue&amp;quot; commandname=&amp;quot;Select&amp;quot; text=&amp;quot;Continue&amp;quot; runat=&amp;quot;server&amp;quot; /&amp;gt;
    &amp;lt;/ItemTemplate&amp;gt;
    &amp;lt;SelectedItemTemplate&amp;gt;
        &amp;lt;h1&amp;gt;&amp;lt;%#Eval(&amp;quot;DataBoundColumn&amp;quot;)%&amp;gt;&amp;lt;/h1&amp;gt;
        
        
        &amp;lt;%-- Handle the ListView_Inserting event --%&amp;gt;
        &amp;lt;p&amp;gt;
            &amp;lt;asp:button id=&amp;quot;btnSubmit&amp;quot; commandname=&amp;quot;Insert&amp;quot; text=&amp;quot;Submit&amp;quot; runat=&amp;quot;server&amp;quot; /&amp;gt;
        &amp;lt;/p&amp;gt;
    &amp;lt;/SelectedItemTemplate&amp;gt;
    &amp;lt;EmptyDataTemplate&amp;gt;
        &amp;lt;p&amp;gt;No Data&amp;lt;/p&amp;gt;
    &amp;lt;/EmptyDataTemplate&amp;gt;
&amp;lt;/asp:listview&amp;gt;&lt;/pre&gt;

&lt;p&gt;In effect, all I am doing is selecting an item... just the regular ItemTemplate is my notice and the SelectedItemTemplate is my actual item.&lt;/p&gt;

&lt;p&gt;You could also use this method to show two different types of forms (but in that case, two pages seems like a better idea).&lt;/p&gt;</description>
      <pubDate>Wed, 15 Jul 2009 20:16:37 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-71</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/4koKZJ2d7HY/how-to-use-a-listview-to-make-people-read-a-s.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/7/15/how-to-use-a-listview-to-make-people-read-a-s.aspx</feedburner:origLink></item>
    <item>
      <title>Yes, You Can Manage Solutions Using Different Source Control Providers</title>
      <description>&lt;p&gt;I had that question today as I just branched a piece of my current project into its own side project on CodePlex. I wondered since I was using TFS as the default source control plug-in in VS.NET whether I couldn't open my SVN-controlled solution. It turns out, you can! Apparently it is solution-scope and not application-scope, so in one VS instance you could have a TFS project open, in the other, your SVN project. That is my current state right now.&lt;/p&gt;  &lt;p&gt;If you're wondering, the project is &lt;a href="http://jformsdotnet.codeplex.com" target="_blank"&gt;jForms.NET&lt;/a&gt;, hosted on CodePlex. I am moving my current code into the new C# project, improving it to support better flexibility for other people's needs. I need to finish it so I can subclass it for my current project to support custom Linq to SQL validation (i.e. no validation controls on forms!), which I will also release later too.&lt;/p&gt;</description>
      <pubDate>Fri, 10 Jul 2009 13:09:46 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-70</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/R9iwNgIhwx0/yes-you-can-manage-solutions-using-different.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/7/10/yes-you-can-manage-solutions-using-different.aspx</feedburner:origLink></item>
    <item>
      <title>Easily Select Controls Using Complex Expressions [Sizzle]</title>
      <description>&lt;p&gt;If you've used jQuery before, you know you want that kind of amazing selector functionality for .NET. The good news is that you can get that kind of complex selecting using a free code snippet called &lt;a href="http://code.google.com/p/ra-ajax/source/browse/trunk/Ra.Selector/Selector.cs"&gt;Ra.Selector&lt;/a&gt;. It supports finding controls by type according to a predicate (boolean expression) and also recursively finding a control by ID.&lt;/p&gt;  &lt;p&gt;I am working on a side project, &lt;a href="http://jformsdotnet.codeplex.com" target="_blank"&gt;jForms.NET&lt;/a&gt;, a component for my current project to automagically manage the code for client validation and default values for web form controls. Basically, only need to define server-side things and it will take care of client-side things.&lt;/p&gt;  &lt;p&gt;One of the things I do is list acceptable control types to search for and collect. My need was to search through the whole page for these controls, no matter where they were, easily letting you (the consumer) drag and drop the control on the page and be done with it.&lt;/p&gt;  &lt;p&gt;The code, using the [modified] selector code, looks like this:&lt;/p&gt;  &lt;pre class="brush: vb;"&gt;' Init member
_allControls = New List(Of Control)

' Iterate through acceptable control types
For Each T As Type In AcceptableControls
    ' Find controls of the type, or that inherit from the type
    ' to support custom subclassed controls
    _allControls.AddRange(Page.FindControls(Of Control)(Function(c) _
    c.GetType() Is T Or c.GetType().IsSubclassOf(T)))
Next&lt;/pre&gt;

&lt;p&gt;So it makes life a lot easier. The original code is GPL licensed in C#. I converted it to VB.NET and modified it to work (since the C# version uses the yield keyword). I am not an expert on license issues but as I understand it, that makes it a new work since I'm not using the original code.&lt;/p&gt;

&lt;p&gt;As another example using &lt;strong&gt;FindFirstControl&lt;/strong&gt;, let's say I wanted to find the first button that had text that began with the letter A:&lt;/p&gt;

&lt;pre class="brush: vb;"&gt;' English: Find first control of type Button in Page where Button.Text starts with &amp;quot;A&amp;quot;
_btnControl = Page.FindFirstControl(Of Button)(Function(b) b.Text.StartsWith(&amp;quot;A&amp;quot;))&lt;/pre&gt;

&lt;p&gt;I am not posting the modified code, just in case it is against the license. All I did was fix some documentation issues, change the name of the methods to match the built-in FindControl, and convert the methods into extension methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The code above was from my project, not the new jForms component. The jForms component is written in C# and looks way cooler than that. More on that later.&lt;/p&gt;</description>
      <pubDate>Fri, 10 Jul 2009 13:07:56 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-69</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/L4GUxdxNz4Q/easily-select-controls-using-complex-expressi.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/7/10/easily-select-controls-using-complex-expressi.aspx</feedburner:origLink></item>
    <item>
      <title>LINQ-to-SQL Bug: Using Property Name vs. DB Column Name for GUIDs</title>
      <description>&lt;p&gt;I came across this error today when working with my LINQ-to-SQL insert logic. &amp;quot;Invalid column name 'Id'.&amp;quot; At first, I didn't understand why it was throwing this error because the source name was correct, &amp;quot;MyColumnRowGuid.&amp;quot;&lt;/p&gt;  &lt;p&gt;I had Auto-Sync set to OnInsert and Auto Generated set to True. I found out that it wasn't my fault, &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=381883"&gt;it's an actual bug&lt;/a&gt; with LINQ-to-SQL. It won't be fixed until .NET 4.0, so I am left to my own devices.&lt;/p&gt;  &lt;p&gt;How did I get around this without changing the column name? I just had Linq use a sproc for the Insert method, generated the ID on the SQL side and returned it as a parameter.&lt;/p&gt;</description>
      <pubDate>Fri, 10 Jul 2009 12:58:21 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-68</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/0gKbZ3wcX9o/linqtosql-bug-using-property-name-vs-db-colum.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/7/10/linqtosql-bug-using-property-name-vs-db-colum.aspx</feedburner:origLink></item>
    <item>
      <title>Announcing Ampersand Adventures [Orientation]</title>
      <description>&lt;p&gt;&lt;a href="http://www.sua.umn.edu/adventure" target="_blank"&gt;&lt;img style="display: inline" title="Ampersand Adventure" alt="Ampersand Adventure" src="http://www.intrepidstudios.com/blog/images/AnnouncingAmpersandAdventuresOrientation_C8C1/image.png" width="720" height="406" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At &lt;a href="http://www.sua.umn.edu" target="_blank"&gt;SUA&lt;/a&gt; we've created introduction video games for freshmen for the past couple years, starting with &lt;a href="http://www.sua.umn.edu/handyandy/keyquest/" target="_blank"&gt;Handy Andy&lt;/a&gt; and subsequently, &lt;a href="http://www.sua.umn.edu/handyandy/" target="_blank"&gt;Handy Andy 2&lt;/a&gt; (which we won an award for). It was time to retire that egg and we took a new approach to our latest installment, &lt;a href="http://www.sua.umn.edu/adventure" target="_blank"&gt;Ampersand Adventure&lt;/a&gt;. It plays more like an interactive story with mini games. Originally I had put out the idea for &lt;a href="http://www.sua.umn.edu/handyandy/HandyAndyIII.jpg" target="_blank"&gt;Handy Andy and the Curse of the Black Squirrel&lt;/a&gt;, but alas, it was not to be.&lt;/p&gt;  &lt;p&gt;I created the Simon Says music game (the last level) and laid the groundwork for the message queuing system that takes an array of messages and shows them in sequence to the user.&lt;/p&gt;  &lt;p&gt;The game was written entirely in JavaScript, PHP, and AJAX using jQuery as the framework. We used SoundManager to manage sound effects. Check out the code to learn more about how we did it.&lt;/p&gt;  &lt;p&gt;Kudos to the rest of the team, &lt;a href="http://lowter.com" target="_blank"&gt;Ethan&lt;/a&gt; and &lt;a href="http://zachstronaut.com" target="_blank"&gt;Zach&lt;/a&gt;, for making another awesome game!&lt;/p&gt;</description>
      <pubDate>Fri, 12 Jun 2009 19:21:28 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-67</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/4HIL3W8O6tU/announcement-ampersand-adventure.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/6/12/announcement-ampersand-adventure.aspx</feedburner:origLink></item>
    <item>
      <title>A Sneak Peek at the BlackJack Game Written in WPF [Awesome]</title>
      <description>&lt;p&gt;Windows Presentation Foundation is a rich framework for building highly interactive and dynamic UIs. In other words, it works really well for simple games (one day I will try my hand at a 2D RPG written in WPF). It's easy for developers already familiar with .NET and its languages to leverage and create awesome client applications (or its web-based equivalent, Silverlight).&lt;/p&gt;  &lt;p&gt;Below is a screen cast of the current state of my BlackJack implementation. As you can see, it works! The basic BlackJack rules are followed and some customization is allowed like the number of decks. AI players use basic logic to either draw or stand, the dealer follows the rules for the table and there are some useful cheats like always dealing a Soft 17, always showing the dealers hole card, etc. It also makes use of simple but effective animations and sounds for drawing and dealing, things that would take a wizard to do as smoothly in Windows Forms.&lt;/p&gt; &lt;object width="720" height="486"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5122176&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=5122176&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="720" height="486"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;p&gt;&lt;a href="http://vimeo.com/5122176"&gt;BlackJack Game Using Windows Presentation Foundation (WPF)&lt;/a&gt; from &lt;a href="http://vimeo.com/user1892349"&gt;Kamran Ayub&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Refer to &lt;a href="http://www.intrepidstudios.com/blog/2009/6/12/whats-the-hold-up-yo-time-is-short.aspx" target="_blank"&gt;my previous post&lt;/a&gt; on when this project will see and meet the world.&lt;/p&gt;</description>
      <pubDate>Fri, 12 Jun 2009 13:53:55 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-66</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/ewiXlo1ZjrU/a-sneak-peek-at-the-blackjack-game-written-in.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/6/12/a-sneak-peek-at-the-blackjack-game-written-in.aspx</feedburner:origLink></item>
    <item>
      <title>A Word on Patterns [Seeing the Light]</title>
      <description>&lt;p&gt;When I started to teach myself .NET and programming, I think that I did a good job. I've been using .NET since 1.0 and have loved it ever since, with more powerful enhancements regularly released. I've used languages starting at HTML and ASP and to more 'modern' languages like C# and XHTML. I can program in a variety of different languages and environments, even dabbling in some C++.&lt;/p&gt;  &lt;p&gt;But, there is a downside to learning on your own and that is that you lack the vocabulary to research effectively. If someone had told me to search for and learn &lt;a href="http://dofactory.com" target="_blank"&gt;patterns&lt;/a&gt;, I think I'd be a more robust, effective, and intelligent software architect/developer now. It wasn't my fault necessarily, how was I to know what the word &amp;quot;pattern&amp;quot; meant in software development. I may have seen it, in fact I know I saw it, but I never knew what it meant so ignored it. Funny thing, my dad gave me a book called &lt;em&gt;Patterns of Enterprise Application Architecture&lt;/em&gt; by some guy named Martin Fowler maybe a year back. I maybe read the first few pages, got bored, and gave it back to him. Wow. I can't even believe I did that, from what I know now and &lt;a href="http://martinfowler.com/" target="_blank"&gt;who he is&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I don't think it's fair to say that I was a bad designer or developer because I didn't know patterns. I realize now, after learning more about them, that I was implementing my own shaky patterns without realizing what it meant. Of course, because of that, my implementations were not as flexible or robust as they would have been had I known how to properly create and envision them. I mean, Torrent Typhoon was one of my best tiered applications even though it may have included some business logic in the presentation layer. It automatically caught and logged errors, elegantly refraining from intimidating the user with scary error pages. It was also so robust, flexible, and accommodating that after refining some code, I hardly ever received error reports or bug reports (that it caught). I may not have known what &amp;quot;Business Objects&amp;quot; were, yet I made them. I may not have known what &amp;quot;Domain Driven Design&amp;quot; was, yet I even did that on my own (albeit less structured and &amp;quot;pure&amp;quot;).&lt;/p&gt;  &lt;p&gt;So here's my advice for .NET newbies or do-it-yourself developers: find someone who's either had formal experience or who has worked on real-world applications. I didn't even realize how much my dad worked with patterns until a few days ago when we got into a conversation about what I was studying.&lt;/p&gt;  &lt;p&gt;My other piece of advice is to be careful. The excellent (and hilarious) book &lt;em&gt;Head First&lt;/em&gt; sums it up: &lt;strong&gt;Don't succumb to Pattern Fever. &lt;/strong&gt;Martin Fowler, the GoF, they're all still developers (smart ones, at that) and not Gods. Maybe a pattern is awesome, but you don't necessarily always need to use it, especially for small, single-user applications. It can also be really overwhelming, with so many developers giving their $0.02 on what to use and what not to use. Even I am still trying to wrap my head around the different patterns and when to use them. Sometimes not thinking about a pattern can result in a creative solution. I used an XML file to store regular expressions that mapped to rows of data from screen-scraped sites for Torrent Typhoon. To fix my results all I had to do was modify the regular expression in &lt;strong&gt;one file&lt;/strong&gt; to conform to the external site's new HTML layout. The engine took care of parsing it and mapping it to data tables, is there a pattern for that? Maybe, but I didn't know that when I created it. I fancied myself pretty damn clever, mind you.&lt;/p&gt;  &lt;p&gt;My last advice (to everyone) is to never think you know everything. &lt;a href="http://www.gladwell.com/" target="_blank"&gt;Malcolm Gladwell's&lt;/a&gt; newest theory purports that it takes 10,000 hours to be considered an expert. That's a LOT of hours. I've been programming back-ends and designing front-ends for the past 9 years and I still don't consider myself to be at the advanced level, I consider myself to be at an intermediate level. I have no qualms with being wrong, I just love to learn new techniques and get advice. Even I get excited and make mistakes or use the wrong wording to describe something. We all do.&lt;/p&gt;  &lt;p&gt;I highly recommend checking out the &lt;a href="http://www.dofactory.com/Framework/Framework.aspx" target="_blank"&gt;Design Pattern Framework 3.5&lt;/a&gt; package for $99. It's a real help, especially for someone like me who knows how to code but isn't super familiar with patterns or how to implement them from &amp;quot;abstract&amp;quot; code samples that you so often find. It comes in both C# and VB.NET. Not only that but it goes hand-in-hand with Head First providing .NET implementations of the Java code samples and also presents Fowler's enterprise patterns, too. I just finished reading the 125-page PDF where it explains an entire real-world eCommerce application implementing real patterns in a useful and easy-to-understand way.&lt;/p&gt;  &lt;p&gt;Books I recommend that I am currently reading are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.amazon.com/gp/product/0735619670?ie=UTF8&amp;amp;tag=intrestudi-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0735619670" target="_blank"&gt;Code Complete by Steve McConnell&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.amazon.com/gp/product/0596007124?ie=UTF8&amp;amp;tag=intrestudi-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0596007124" target="_blank"&gt;Head First by Freeman[s], Bates, and Sierra&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.amazon.com/exec/obidos/ASIN/0321127420" target="_blank"&gt;Patterns of Enterprise Application Architecture by Martin Fowler&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;</description>
      <pubDate>Fri, 12 Jun 2009 04:10:34 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-65</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/5kCJeW3kTzc/a-word-on-patterns-seeing-the-light.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/6/12/a-word-on-patterns-seeing-the-light.aspx</feedburner:origLink></item>
    <item>
      <title>What's the Hold Up, Yo? [Time is Short]</title>
      <description>&lt;p&gt;I have mentioned before my intent to post my Black Jack WPF implementation for public use and fun, to showcase object-oriented concepts and full use of animations/sounds/timelines in WPF. Really it's to show how even in .NET you can create games, if you put your mind to it. It is complete in the limited sense of the word, meaning that it runs fine and plays fine but is missing some AI logic.&lt;/p&gt;  &lt;p&gt;To be frank, after reading some more books on OO-development in general, I realize in hindsight that it is not using the most efficient and accurate OO-design. In addition, it doesn't use any decent &lt;a href="http://dofactory.com" target="_blank"&gt;patterns&lt;/a&gt; except Observers and Singletons. For a WPF application, I should really be leveraging the &lt;a href="http://weblogs.asp.net/craigshoemaker/archive/2009/02/26/hands-on-model-view-viewmodel-mvvm-for-silverlight-and-wpf.aspx" target="_blank"&gt;MVVM&lt;/a&gt; pattern. I am currently in the process of studying different enterprise, Gang of Four, and other patterns that I think will benefit my development greatly. Because of this, I am holding off on releasing the app so that I can refactor it into a more educational lesson of good architecture design.&lt;/p&gt;  &lt;p&gt;The other project I have whispered about is re-releasing Torrent Typhoon as an open source framework for torrent searching. I could just release what I have but what I have is not really suitable for the public. Nor does it offer would I really want to achieve: a server-oriented architecture. Can you imagine? Torrent searching on the cloud, from any client you want. You could download the framework and write a web application, Windows Forms application, WPF application, BlackBerry application, iPhone application, any application that can consume a WCF service, that's the dream I have.&lt;/p&gt;  &lt;p&gt;What I am learning and studying now will eventually motivate me to &amp;quot;fix&amp;quot; my projects. When will that day come? Who knows. Months. Years. Just watch out for it.&lt;/p&gt;</description>
      <pubDate>Fri, 12 Jun 2009 03:37:47 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-64</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/Fox6QLJ6oxc/whats-the-hold-up-yo-time-is-short.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/6/12/whats-the-hold-up-yo-time-is-short.aspx</feedburner:origLink></item>
    <item>
      <title>Random .NET Tips &amp; Tricks: Using, LINQ, Initializers, and Config Encryption [VB.NET]</title>
      <description>&lt;p&gt;I've just started my summer internship at General Mills and while I can't talk a lot about the different things I'll be working on or have seen (on pain of death), I can at least share with you the random tips I've picked up through my .NET training and work.&lt;/p&gt;  &lt;h3&gt;Are You Using &lt;em&gt;Using&lt;/em&gt;?&lt;/h3&gt;  &lt;p&gt;A neat little VB.NET/C# statement that I never knew much about was the &lt;var&gt;Using&lt;/var&gt; keyword. What does it do? It works with any type that implements the &lt;var&gt;IDisposable&lt;/var&gt; interface. When the &lt;code&gt;End Using&lt;/code&gt; statement is hit, &lt;strike&gt;.NET will &lt;em&gt;immediately&lt;/em&gt; clean up the object, rather than marking it as &amp;quot;trash this&amp;quot; which is what it normally does&lt;/strike&gt; .NET calls the Dispose() method of the object. &lt;strong&gt;Update:&lt;/strong&gt; A helpful soul clarified exactly what &lt;var&gt;Using&lt;/var&gt; is for and why it's nice. &lt;var&gt;Using&lt;/var&gt; is useful because it has a cleaner syntax and you don't have to use &lt;var&gt;Finally&lt;/var&gt; blocks to check if your object is &lt;var&gt;Nothing&lt;/var&gt; to dispose it. For more discussion on VB.NET's &lt;var&gt;Using&lt;/var&gt;, &lt;a href="http://www.pluralsight.com/community/blogs/fritz/archive/2005/04/28/7834.aspx"&gt;check out this post&lt;/a&gt; and Hexar's comment showing the typical syntax pre-&lt;var&gt;Using&lt;/var&gt;.&lt;/p&gt;  &lt;p&gt;Here's an example (note: pseudocode):&lt;/p&gt;  &lt;pre class="brush: vb;"&gt;Using conn As New SqlConnection(blah)
    conn.Open()
    
    Dim cmd As New SqlCommand(blah)

    Using rdr As IDataReader = cmd.ExecuteReader()
        While rdr.Read()
            ' Do stuff
        End While
    End Using ' Disposes DataReader

End Using ' Disposes conn&lt;/pre&gt;

&lt;p&gt;It's not an amazing thing, but it will trim some of your code and make it easier to recognize blocked code.&lt;/p&gt;

&lt;p&gt;Check out &lt;a href="http://www.developer.com/net/csharp/article.php/3724626" target="_blank"&gt;this C# article on Using statements&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;LINQ Tips&lt;/h3&gt;

&lt;p&gt;This is VB-specific, but when making a LINQ statement and you want to return the full result set, you do not need the &lt;var&gt;select&lt;/var&gt; statement (pseudocode):&lt;/p&gt;

&lt;pre class="brush: vb;"&gt;Dim q = from p in db.Products _
        where p.Price &amp;gt; 5&lt;/pre&gt;

&lt;p&gt;You can also return new objects using anonymous types, in case you want to create a custom object that only uses what you need (pseudocode):&lt;/p&gt;

&lt;pre class="brush: vb;"&gt;Dim q = from p in db.Products _
        where p.Price &amp;gt; 5 _
        select new { _
            .SKU = &amp;quot;SKPID&amp;quot; &amp;amp; p.ProductID &amp;amp; &amp;quot;M&amp;quot; &amp;amp; p.Manufacturer, _
            .Price = p.Price }&lt;/pre&gt;

&lt;h3&gt;Object Initializers&lt;/h3&gt;

&lt;p&gt;I didn't know much about the new object initialization method introduced in C# 3.0 and VB9 until today. A lot of people pass in properties through the constructor of an object when initializing it. This has multiple shortcomings. What if you wanted to only provide one property? You could have an if statement or pass in &lt;var&gt;Nothing&lt;/var&gt;… but soon this would become a lot of extra work.&lt;/p&gt;

&lt;p&gt;Using this method, here's how you would create a fake entity called &amp;quot;Person&amp;quot; using typical properties:&lt;/p&gt;

&lt;pre class="brush: vb;"&gt;Dim newPerson As New Person ' no constructor
newPerson.Name = &amp;quot;Harold&amp;quot;
newPerson.Age = 25
newPerson.City = &amp;quot;Footown&amp;quot;
arrPersons.Add(newPerson)

newPerson = New Person
newPerson.Name = &amp;quot;blahblahblah&amp;quot;
' Repeat ad infinitum&lt;/pre&gt;

&lt;p&gt;So, there's got to be a better way, right? Right! You can use the &lt;var&gt;With&lt;/var&gt; statement and with it (heh) you can easily and quickly initialize new objects.&lt;/p&gt;

&lt;pre class="brush: vb;"&gt;arrPersons.Add(New Person With { _
                .Name = &amp;quot;Harold&amp;quot;, _
                .Age = 25, _
                .City = &amp;quot;FooTown&amp;quot; })

arrPersons.Add(New Person With { _
                .Name = &amp;quot;blahblahblah&amp;quot; })

' Repeat
' Note: regular initialization using With
Dim newPerson As New Person With { .Name = &amp;quot;Foo&amp;quot; }&lt;/pre&gt;

&lt;p&gt;Check out this &lt;a href="http://blog.dmbcllc.com/2007/11/28/object-initialization-in-csharp-30-and-vbnet-9/" target="_blank"&gt;screencast and article&lt;/a&gt; about the topic.&lt;/p&gt;

&lt;h3&gt;Encrypt Your Web.Config&lt;/h3&gt;

&lt;p&gt;I never knew about this but apparently you can &lt;a href="http://www.developerfusion.com/code/5263/encrypting-webconfig-sections-in-aspnet-20/" target="_blank"&gt;encrypt sections of your web.config file&lt;/a&gt;. Why would you do this, can't the public already not access it? Yes, but your programmers, administrators, and employees can. Sometimes you need to put in an extra level of protection, for example to protect database connections, and in that case, you should think about encrypting your connection strings section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; .NET will encrypt sections that are both in the &lt;strong&gt;web.config&lt;/strong&gt; file and config files referenced by web.config (for example, &amp;quot;connections.config&amp;quot;).&lt;/p&gt;</description>
      <pubDate>Thu, 28 May 2009 04:46:16 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-62</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/QcGjln8DBJE/random-dot-net-tips-and-tricks.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/5/28/random-dot-net-tips-and-tricks.aspx</feedburner:origLink></item>
    <item>
      <title>Get the First Paragraph of Text of a String [Helpers]</title>
      <description>&lt;p&gt;This is a simple PHP function (that can easily be replicated in .NET) that will take a string and get the first paragraph of text it can find. Works with HTML and plain text.&lt;/p&gt;  &lt;p&gt;We use it on the &lt;a href="http://www.homecoming.umn.edu" target="_blank"&gt;UMN Homecoming site&lt;/a&gt; for the &amp;quot;Latest Blog Post.&amp;quot;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In PHP:&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="brush: php;"&gt;/**
 * Simple function gets first paragraph of text, supports HTML or plain text.
 *
 * @author Kamran Ayub
 * @param {String} $data The string to summarize
 * @param {Boolean} $isHTML Whether or not the string contains HTML
 */
function string_summarize($data, $isHTML = true) {    
    
    $result = $data;
    
    if($isHTML) {
        
        // convert line breaks/paragraphs
        $result = str_replace(&amp;quot;\n&amp;quot;, &amp;quot;&amp;quot;, $result); // remove extra
        $result = str_replace(&amp;quot;&amp;lt;br&amp;gt;&amp;quot;, &amp;quot;\n&amp;quot;, $result);
        $result = str_replace(&amp;quot;&amp;lt;br/&amp;gt;&amp;quot;, &amp;quot;\n&amp;quot;, $result);
        $result = str_replace(&amp;quot;&amp;lt;br /&amp;gt;&amp;quot;, &amp;quot;\n&amp;quot;, $result);
        $result = str_replace(&amp;quot;&amp;lt;/p&amp;gt;&amp;quot;, &amp;quot;\n\n&amp;quot;, $result);
    
        // strip all remaining tags
        $result = strip_tags($result);
    }
    
    // try and return the first paragraph, if I can't, return all of it
    $paragraphs = explode(&amp;quot;\n\n&amp;quot;, trim($result));
    
    if(count($paragraphs) &amp;gt; 1) {
        return nl2br(trim($paragraphs[0]));
    } else {
        return $data;
    }
}&lt;/pre&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;</description>
      <pubDate>Wed, 20 May 2009 16:50:37 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-61</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/Gyl4bspPMAI/get-the-first-paragraph-of-text-of-a-string-h.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/5/20/get-the-first-paragraph-of-text-of-a-string-h.aspx</feedburner:origLink></item>
    <item>
      <title>RegEx: Get the array of values for a SET/ENUM in MySQL [Snippet]</title>
      <description>&lt;p&gt;Need a fast and easy way to generate an array of the different values for a SET or ENUM data type in MySQL? This example assumes you've already retrieved the value of the &amp;quot;Type&amp;quot; column. For information on how to do this, read this &lt;a href="http://dev.mysql.com/tech-resources/articles/mysql-set-datatype.html#members" target="_blank"&gt;MySQL article on the SET datatype&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In PHP:&lt;/p&gt;  &lt;pre class="brush: php;"&gt;// input format: set('item','item2','item3')
// strip set() and quotes
$strType = preg_replace(&amp;quot;/^(set|enum)\(|[']+|\)$/i&amp;quot;, &amp;quot;&amp;quot;, $strType);

// assign to the array
$arr = split(',', $strType);&lt;/pre&gt;

&lt;p&gt;In C#:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;// imports
using System.Text.RegularExpressions;

// input format: set('item','item2','item3')
// strip set() and quotes
strType = RegEx.Replace(strType, &amp;quot;^(set|enum)\(|[']+|\)$&amp;quot;, 
                String.Empty, RegExOptions.IgnoreCase);

// assign to the array
arrTypes = strType.Split(',');&lt;/pre&gt;

&lt;p&gt;And there you go! Enjoy.&lt;/p&gt;</description>
      <pubDate>Thu, 14 May 2009 18:06:02 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-60</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/rATkHt9t2Y4/regex-get-the-array-of-values-for-a-setenum-i.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/5/14/regex-get-the-array-of-values-for-a-setenum-i.aspx</feedburner:origLink></item>
    <item>
      <title>Release: Phyllis Wheatley Community Lawyering Project [PHP]</title>
      <description>&lt;p&gt;&lt;a href="http://www.intrepidstudios.com/blog/images/ReleasePhyllisWheatleyCommunityLawyering_9A2D/image.png"&gt;&lt;img style="display: inline" title="image" alt="image" src="http://www.intrepidstudios.com/blog/images/ReleasePhyllisWheatleyCommunityLawyering_9A2D/image_thumb.png" width="425" height="325" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We’ve released a new web site, the&lt;strong&gt; &lt;/strong&gt;&lt;a href="http://clp.phylliswheatley.org" target="_blank"&gt;&lt;strong&gt;Phyllis Wheatley Community Lawyering Project&lt;/strong&gt;&lt;/a&gt;.&amp;#160; The cool thing about this site is the jQuery animation on the homepage (above) that degrades gracefully for non-Javascript enabled browsers (i.e. progressive enhancement). We also customized the WordPress template to match the rest of the site, which was easier than I thought.&lt;/p&gt;  &lt;p&gt;You can learn more about what we provided the PWCLP with &lt;a href="http://intrepidstudios.com/designs/view/pwclp" target="_blank"&gt;on its project page&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;This site was done for a real client in one of my classes and I’ve credited my team on the project page. I’d like to thank them again here:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Jena Barch, Content Editor&lt;/li&gt;    &lt;li&gt;Michael Ramlet, Project Manager&lt;/li&gt;    &lt;li&gt;Kevin Yu, Creative Input&lt;/li&gt;    &lt;li&gt;Erin Soletski, Creative Input&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Thanks team!&lt;/p&gt;</description>
      <pubDate>Thu, 14 May 2009 15:59:01 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-59</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/8S0Kj7sZOkE/release-phyllis-wheatley-community-lawyering.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/5/14/release-phyllis-wheatley-community-lawyering.aspx</feedburner:origLink></item>
    <item>
      <title>We've Won an Award! [Video Games]</title>
      <description>&lt;p&gt;I can now say I have officially worked on an award-winning video game. My boss, mentor, and friend, &lt;a href="http://zachstronaut.com" target="_blank"&gt;Zach Johnson&lt;/a&gt;, and I have been awarded the Maroon Award for Electronic Media and Education from the University of Minnesota Communications Forum for our work on &lt;a href="http://www.sua.umn.edu/handyandy" target="_blank"&gt;Handy Andy 2: The Ampersand Trail&lt;/a&gt; video game.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.intrepidstudios.com/blog/images/WeveWonanAwardVideoGames_8B34/image.png"&gt;&lt;img style="display: inline" title="Handy Andy 2 won an award!" alt="Handy Andy 2 won an award!" src="http://www.intrepidstudios.com/blog/images/WeveWonanAwardVideoGames_8B34/image_thumb.png" width="520" height="390" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here's looking to win an award for next year's game we're working on!&lt;/p&gt;</description>
      <pubDate>Fri, 08 May 2009 15:01:12 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-58</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/O08nIKtti1g/weve-won-an-award-video-games.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/5/8/weve-won-an-award-video-games.aspx</feedburner:origLink></item>
    <item>
      <title>Easy Data-Driven UI Using Windows Forms [.NET]</title>
      <description>&lt;p&gt;It's a common need in developing software to change control values based on data from a database or a property on an object. For example, choosing a customer name in a ListBox and filling in all their details into some form controls. You might first begin by implementing code in &lt;code&gt;OnSelectedIndexChanged&lt;/code&gt; events, &lt;code&gt;OnTextChanged&lt;/code&gt; events, etc.&lt;/p&gt;  &lt;p&gt;Luckily, there's a very easy way to bind data to Windows Forms controls using a database, web service, or an actual object you've created. It's called the &lt;code&gt;BindingSource&lt;/code&gt; control.&lt;/p&gt;  &lt;h3&gt;What is a BindingSource?&lt;/h3&gt;  &lt;p&gt;A &lt;code&gt;BindingSource&lt;/code&gt; creates two-way databinding between some data source and a Windows Forms control. Data sources include a database, web services, or objects. &lt;/p&gt;  &lt;p&gt;The easiest way to explain it is to give you some hands-on experience. In this tutorial I will have you build a simple UI and bind some data to it. We're going to build a simple application that will view and edit some customer data.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://intrepidstudios.com/projects/samples/releases/article-ui-binding/1.0/" target="_blank"&gt;Download Source Code for this Tutorial (PDF of article included)&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Building the UI&lt;/h3&gt;  &lt;p&gt;We're going to keep this short and simple. We want to be able to list some customers, edit their data, and manage their pet information.&lt;/p&gt;  &lt;p&gt;Create a new C# Windows Application project and open up Form1.&lt;/p&gt;  &lt;p&gt;First, let's add a &lt;code&gt;ListBox&lt;/code&gt; control for listing customer names:&lt;/p&gt;  &lt;p&gt;&lt;img style="display: inline" title="customerlistbox" alt="customerlistbox" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/customerlistbox.png" width="520" height="298" /&gt; &lt;/p&gt;  &lt;p&gt;Next, drag some labels and &lt;code&gt;TextBox&lt;/code&gt; controls for the customers' Name, Email, and Phone Number. Position them however you want.&lt;/p&gt;  &lt;p&gt;&lt;img style="display: inline" title="textandlabels" alt="textandlabels" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/textandlabels.png" width="520" height="298" /&gt; &lt;/p&gt;  &lt;p&gt;Drag a &lt;code&gt;DataGridView&lt;/code&gt; to the form.&lt;/p&gt;  &lt;p&gt;&lt;img style="display: inline" title="datagrid" alt="datagrid" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/datagrid.png" width="520" height="298" /&gt; &lt;/p&gt;  &lt;p&gt;All done! Our UI is complete for this tutorial. Let's move on to the fun part.&lt;/p&gt;  &lt;h3&gt;Creating Some Data&lt;/h3&gt;  &lt;p&gt;We are listing customers and their pets but because I don't want to have you create data in a database, we're going to create some classes with our data. I find it more cool to bind to actual objects and I think it's more helpful than going over database binding because typically you'd create entities like this anyway.&lt;/p&gt;  &lt;p&gt;First, let's create our &lt;var&gt;Customer&lt;/var&gt; class. Right-click your project, click Add –&amp;gt; Class… and name it &lt;strong&gt;Customer.cs:&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BindingSourceTutorial
{
    public class Customer
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public string PhoneNumber { get; set; }

        // My Pets
        public List&amp;lt;Pet&amp;gt; Pets { get; set; }

        protected Customer()
        {
            // force NewCustomer method
        }

        public static Customer NewCustomer(int id, string name, 
            string email, string phoneNumber)
        {
            Customer c = new Customer();
            c.ID = id;
            c.Name = name;
            c.Email = email;
            c.PhoneNumber = phoneNumber;
            c.Pets = new List&amp;lt;Pet&amp;gt;();

            return c;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Make sure to declare you classes &lt;var&gt;public&lt;/var&gt;!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you can probably see, we've created the customer's attributes (properties) and we've created a method called &lt;code&gt;NewCustomer(...)&lt;/code&gt; that returns a new customer with our desired attributes. I added the ID property to hold a unique ID for a customer, it's not really needed for this tutorial. You may have also noticed I made the constructor &lt;var&gt;protected&lt;/var&gt;. This is just a common pattern to use when creating &amp;quot;business objects,&amp;quot; because sometimes you'd like to save this data to a file and load it, and when .NET loads data from a file it does not support constructor parameters (at least for &lt;var&gt;XMLSerializer&lt;/var&gt;, but that's for another day).&lt;/p&gt;

&lt;p&gt;Next, let's create our &lt;var&gt;Pet&lt;/var&gt; class, name it &lt;strong&gt;Pet.cs&lt;/strong&gt;. &lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BindingSourceTutorial
{
    public class Pet
    {
        public string Name { get; set; }
        public string Type { get; set; }
        public string Age { get; set; }

        protected Pet()
        {
            // force NewPet method
        }

        public static Pet NewPet(string name, string type, string age)
        {
            Pet p = new Pet();
            p.Name = name;
            p.Type = type;
            p.Age = age;

            return p;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;We now have a &lt;var&gt;Pet&lt;/var&gt; class that has a Name, Type, and Age. Customers have pets, so if you had a database this would be a many-to-one relationship. We will model that by going back to our &lt;strong&gt;Customer.cs&lt;/strong&gt; file and adding a new property, underneath PhoneNumber:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;// My Pets
public List&amp;lt;Pet&amp;gt; Pets { get; set; }&lt;/pre&gt;

&lt;p&gt;If you're not familiar with the generics, then the &lt;code&gt;List&amp;lt;Pet&amp;gt;&lt;/code&gt; type might be confusing to you. Since .NET 2.0, we can create what's called a generic type. For example, instead of creating an array of Pets like &lt;code&gt;public Pet[] PetsArray { get; set; }&lt;/code&gt; we create a &lt;var&gt;List&lt;/var&gt; of type &lt;var&gt;Pet&lt;/var&gt;. A &lt;var&gt;List&lt;/var&gt; is a generic that has become a lot more powerful with the introduction of &lt;a href="http://www.4guysfromrolla.com/articles/021809-1.aspx" target="_blank"&gt;LINQ extension methods&lt;/a&gt;. Using a generic list exposes more functionality than an array would (like Where, Distinct, Any, All, etc) that almost make it as if you're using SQL to get the objects you want. If you're interested, read up on &lt;a href="http://msdn.microsoft.com/en-us/library/512aeb7t.aspx" target="_blank"&gt;Generics&lt;/a&gt; and &lt;a href="http://www.hookedonlinq.com/LINQtoObjects5MinuteOverview.ashx" target="_blank"&gt;LINQ to Objects&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, we are finished with creating our data schema, so let's bind some data!&lt;/p&gt;

&lt;p&gt;In order to browse the list of customers, we need a property that holds the list. To keep things simple, let's just add a property to our &lt;strong&gt;Form1.cs:&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BindingSourceTutorial
{
    public partial class Form1 : Form
    {

        public List&amp;lt;Customer&amp;gt; Customers { get; set; }

        public Form1()
        {
            InitializeComponent();
        }
    }
}&lt;/pre&gt;

&lt;h3&gt;Binding the Interface&lt;/h3&gt;

&lt;p&gt;Let's set up our BindingSources now. Press &lt;strong&gt;Ctrl-Shift-B&lt;/strong&gt; to build the project.&lt;/p&gt;

&lt;p&gt;Click our Customers &lt;code&gt;ListBox&lt;/code&gt; control and click the little arrow in the top right corner. &lt;/p&gt;

&lt;p&gt;Click &amp;quot;Use data bound items.&amp;quot; Click the &amp;quot;Data Source&amp;quot; drop-down and then the &amp;quot;Add Project Data Source…&amp;quot; link to start the new data source wizard.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="listbox_datasource_1" alt="listbox_datasource_1" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/listbox_datasource_1.png" width="520" height="372" /&gt; &lt;/p&gt;

&lt;p&gt;Select &amp;quot;Object,&amp;quot; click Next, then browse to: BindingSourceTutorial –&amp;gt; Form1. Click Finish.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="listbox_form1" alt="listbox_form1" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/listbox_form1.png" width="309" height="166" /&gt; &lt;/p&gt;

&lt;p&gt;Notice how the designer has created a &amp;quot;form1BindingSource&amp;quot; control. However, we haven't chosen the &lt;var&gt;Customers&lt;/var&gt; data source yet. Click &amp;quot;Data Source&amp;quot; again and expand the &amp;quot;form1BindingSource&amp;quot; and click &amp;quot;Customers.&amp;quot; Now we've chosen the &lt;var&gt;Customers&lt;/var&gt; data source and the designer has created an associated control, &amp;quot;customersBindingSource.&amp;quot;&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="listbox_customers" alt="listbox_customers" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/listbox_customers.png" width="279" height="184" /&gt; &lt;/p&gt;

&lt;p&gt;So now click the &amp;quot;Display Member&amp;quot; drop down and choose &amp;quot;Name.&amp;quot; This is the property that will be displayed in the &lt;code&gt;ListBox&lt;/code&gt; control. Click the &amp;quot;Value Member&amp;quot; drop-down and choose &amp;quot;ID.&amp;quot; This is the property that the &lt;code&gt;ListBox&lt;/code&gt; item's value will be.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="listbox_value_display" alt="listbox_value_display" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/listbox_value_display.png" width="281" height="192" /&gt; &lt;/p&gt;

&lt;p&gt;If you build and run the project now, nothing will show up in the Customer &lt;code&gt;ListBox&lt;/code&gt;. That's what's supposed to happen, since we haven't created any data yet.&lt;/p&gt;

&lt;p&gt;Now, let's bind the rest of the controls. For non-list style controls, you need to go into the Properties window and expand the &amp;quot;(Data Bindings)&amp;quot; attribute. For the &lt;code&gt;TextBox&lt;/code&gt; controls, select the Text attribute and click the drop-down. Expand &amp;quot;customersBindingSource&amp;quot; and choose the appropriate attribute.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="textbox_databinding" alt="textbox_databinding" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/textbox_databinding.png" width="324" height="437" /&gt; &lt;/p&gt;

&lt;p&gt;For the &lt;code&gt;DataGridView&lt;/code&gt;, select it and click the white arrow in the top right corner. Select Data Source, expand &amp;quot;customersBindingSource,&amp;quot; and select Pets.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="datagrid_pets" alt="datagrid_pets" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/datagrid_pets.png" width="294" height="317" /&gt; &lt;/p&gt;

&lt;p&gt;Notice how the &lt;code&gt;DataGridView&lt;/code&gt; automatically creates all the columns! Like always, the designer has created a &amp;quot;petsBindingSource.&amp;quot; So cool.&lt;/p&gt;

&lt;p&gt;Lastly, we want to be able to add and remove pets, so click the &amp;quot;petsBindingSource&amp;quot; and set the &amp;quot;AllowNew&amp;quot; property to &lt;strong&gt;true&lt;/strong&gt;. Notice how the &lt;code&gt;DataGridView&lt;/code&gt; automatically added a row to allow adding records.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="pets_allownew" alt="pets_allownew" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/pets_allownew.png" width="326" height="240" /&gt; &lt;/p&gt;

&lt;h3&gt;Hooking Everything Up&lt;/h3&gt;

&lt;p&gt;Now our BindingSources are created! Now all we need to do is simulate actual data by making some ourselves when the form loads up. Then we just assign the data sources!&lt;/p&gt;

&lt;p&gt;Double-click your Form1 so we can create some data:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;private void Form1_Load(object sender, EventArgs e)
{
    // Initialize
    Customers = new List&amp;lt;Customer&amp;gt;();

    // Create customers
    Customers.Add(Customer.NewCustomer(1, 
        &amp;quot;Bob the Builder&amp;quot;, 
        &amp;quot;bob@buildings.com&amp;quot;, 
        &amp;quot;123-456-9876&amp;quot;));
    Customers.Add(Customer.NewCustomer(2, 
        &amp;quot;Sara Cuttingham&amp;quot;, 
        &amp;quot;ham@cutting.com&amp;quot;, 
        &amp;quot;123-456-1234&amp;quot;));
    Customers.Add(Customer.NewCustomer(3, 
        &amp;quot;Tony Spumoni&amp;quot;, 
        &amp;quot;tony@spumonis.com&amp;quot;, 
        &amp;quot;234-543-8765&amp;quot;));
    Customers.Add(Customer.NewCustomer(4, 
        &amp;quot;Butch McBuffpants&amp;quot;, 
        &amp;quot;bench274@bodybuilders.com&amp;quot;, 
        &amp;quot;123-564-1276&amp;quot;));

    // Now create their pets!
    // Bob
    Customers[0].Pets.Add(Pet.NewPet(&amp;quot;Fluffy&amp;quot;, &amp;quot;Cat&amp;quot;, 12));
    Customers[0].Pets.Add(Pet.NewPet(&amp;quot;Ruffles&amp;quot;, &amp;quot;Dog&amp;quot;, 5));
    // Sara
    Customers[1].Pets.Add(Pet.NewPet(&amp;quot;Charles&amp;quot;, &amp;quot;Guinea Pig&amp;quot;, 45));
    // Tony
    Customers[2].Pets.Add(Pet.NewPet(&amp;quot;Sunshine&amp;quot;, &amp;quot;Fish&amp;quot;, 2));
    Customers[2].Pets.Add(Pet.NewPet(&amp;quot;Rascal&amp;quot;, &amp;quot;Fish&amp;quot;, 1));
    Customers[2].Pets.Add(Pet.NewPet(&amp;quot;Chainsaw&amp;quot;, &amp;quot;Cat&amp;quot;, 3));
    // Butch has no pets :(

    // Always cite your sources
    customersBindingSource.DataSource = Customers;
}&lt;/pre&gt;

&lt;p&gt;So, now we have our dataset! But why are we only binding one data source? That's because the rest of the controls on the page only use the &lt;var&gt;customersBindingSource&lt;/var&gt;, so there's no need to bind anything else!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cool Tips:&lt;/strong&gt; Notice how we just bound the data source to the Customers List, just as it was created. What if we wanted to sort the data? Then we could do:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;customersBindingSource.DataSource = Customers.OrderBy(c =&amp;gt; c.Name);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What if we only wanted customers with pets?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;customersBindingSource.DataSource = Customers.Where(c =&amp;gt; c.Pets.Count &amp;gt; 0).ToList();&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Cool, eh?&lt;/p&gt;

&lt;p&gt;Press F5 and witness the magic. Try editing, add or removing pets, and selecting other customers. All your changes are saved.&lt;/p&gt;

&lt;h3&gt;There's an Even Faster Way!&lt;/h3&gt;

&lt;p&gt;Now I am going to blow your mind and you may hate me for it. Open up the Data Sources tab by clicking View –&amp;gt; Data Sources.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="datasources" alt="datasources" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/datasources.png" width="306" height="520" /&gt; &lt;/p&gt;

&lt;p&gt;Expand the Form1 data source and click the Customers property. Click the drop-down arrow and select &amp;quot;Customize…&amp;quot; then choose &lt;code&gt;ListBox&lt;/code&gt; in the checkbox list. You can click &amp;quot;Set Default&amp;quot; if you want.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="customize_datasource" alt="customize_datasource" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/customize_datasource.png" width="520" height="312" /&gt; &lt;/p&gt;

&lt;p&gt;Now, click the drop-down again and select &lt;code&gt;ListBox&lt;/code&gt;. Then drag the Customers property onto the form.&lt;/p&gt;

&lt;p&gt;Magically, a binding source, a binding navigator, and a &lt;code&gt;ListBox&lt;/code&gt; control are created.&lt;/p&gt;

&lt;p&gt;&lt;img style="display: inline" title="bindingnavigator" alt="bindingnavigator" src="http://www.intrepidstudios.com/blog/images/EasyDataDrivenUIUsingWindowsForms.NET_C449/bindingnavigator.png" width="503" height="390" /&gt;&lt;/p&gt;

&lt;p&gt;To recreate our form, we don't need a binding navigator so you can just delete it. &lt;/p&gt;

&lt;p&gt;Now just drag the rest of the properties of Customers from the Data Sources pane onto the form. Be sure to select &lt;code&gt;DataGridView&lt;/code&gt; for the Pets property.&lt;/p&gt;

&lt;p&gt;Run it and voila, all done! See, we didn't even have to manually associate all the controls! I know you may be angry, but I think it is better to show you the foundation so you understand the concepts before telling you how to make it easier.&lt;/p&gt;

&lt;p&gt;Have fun and remember, always cite your sources! &lt;/p&gt;

&lt;h3&gt;Questions You May Have&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Q. Can I bind two controls to the same exact BindingSource control?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. &lt;/strong&gt;Yes, but data will be reflected by both of them. This causes trouble when trying to bind two &lt;code&gt;ListBox&lt;/code&gt; controls to one BindingSource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Can I have a list item's selected item be bound to a value?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; Of course, just follow the same method as a &lt;code&gt;TextBox&lt;/code&gt; control except bind the value to the SelectedValue property. If binding to a &lt;code&gt;ComboBox&lt;/code&gt; that allows editing, I recommend binding to the Text property.&lt;/p&gt;</description>
      <pubDate>Fri, 01 May 2009 22:51:44 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-57</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/SUhbQ6zHI1g/data-driven-ui-binding-windows-forms.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/5/1/data-driven-ui-binding-windows-forms.aspx</feedburner:origLink></item>
    <item>
      <title>So you want to be a .NET developer…</title>
      <description>&lt;p&gt;My friend and colleague &lt;a href="http://www.zachstronaut.com/posts/2009/04/20/advice-for-new-web-developers.html" target="_blank"&gt;Zach Johnson posted a great article&lt;/a&gt; on beginning web development. His post is mostly focused on PHP/MySQL due to his background, so I thought I'd expand on his excellent advice by talking about beginning .NET development.&lt;/p&gt;  &lt;p&gt;Firstly, let's get something out of the way: .NET is not a programming language, it's a programming framework. The .NET framework supports three languages that can be used for web development: C#, VB.NET (VB 8), and J# (which no one uses).&lt;/p&gt;  &lt;h3&gt;Why Should I Develop Using .NET?&lt;/h3&gt;  &lt;p&gt;The answer to this question has a lot of facets. I chose .NET because I was not only interested in web development but I also was interested in Windows development. The great thing about .NET is that it's not hard to move between client and web development since you can use whatever language you prefer for both environments. Additionally, with the recent release of &lt;a href="http://windowsclient.net/getstarted/" target="_blank"&gt;Windows Presentation Foundation&lt;/a&gt; with .NET Framework 3.5, client development is like developing a rich web application because the UI is all XML (or more properly: XAML) driven and supports rich graphical features like timeline animations, transparency, and much more than what Windows Forms can offer you. Silverlight is the technology most people associate with XAML interfaces but WPF lets you create native Windows applications using the same UI tools like Microsoft Expression.&lt;/p&gt;  &lt;p&gt;If you have no interest in client development, ASP.NET still has enough going for it to warrant your notice. I've found that ASP.NET is great at making database-driven sites in a short amount of time. There are no templates, modules, or code that you have to set up to dive into making a data-driven web application. It's as simple as opening a new ASPX page, dropping an &lt;var&gt;SqlDataSource&lt;/var&gt; control and linking it to a table to pull whatever data you need and filling a &lt;var&gt;ListView&lt;/var&gt; control to show a list. No DB connection code, you don't even need to code unless you want to customize the results that are returned.&lt;/p&gt;  &lt;h3&gt;So How Do I Get Started?&lt;/h3&gt;  &lt;p&gt;Developing using the .NET framework has come a long, long way since I started. Not only is it all free now, but in recent months there's been a lot of awesome add-ons to speed up data-driven web sites. &lt;/p&gt;  &lt;p&gt;If .NET development interests you, here are my recommendations: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Go and get &lt;a href="http://www.microsoft.com/Express/" target="_blank"&gt;Visual Web Developer 2008&lt;/a&gt;:&amp;#160; It's free and is just as good as the full VS 2008, minus support for built-in team source code development. &lt;/li&gt;    &lt;li&gt;Go and get &lt;a href="http://www.microsoft.com/express/sql/default.aspx" target="_blank"&gt;SQL Server 2008 Express&lt;/a&gt;: Again, it's free and is good enough for development environments. &lt;/li&gt;    &lt;li&gt;Start learning C# and then get at least familiar with VB. Many people still use VB applications and it could be useful to know both, I do. They aren't extremely different but C# is smoother and more efficient (VB is slower). It's also similar to JavaScript's syntax so while you're learning JavaScript, C# should come naturally. Besides, there are some great &lt;a href="http://www.developerfusion.com/tools/convert/csharp-to-vb/" target="_blank"&gt;translation tools&lt;/a&gt; that make moving between languages simple. &lt;/li&gt;    &lt;li&gt;Buy some books. You can learn a lot on the Internet but I learned more through the books I bought. Any of the Pro series (yellow and black) books are usually good. &lt;/li&gt;    &lt;li&gt;If you're low on cash, I recommend looking at sites like:      &lt;ul&gt;       &lt;li&gt;&lt;a href="http://4guysfromrolla.com"&gt;http://4guysfromrolla.com&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/" target="_blank"&gt;ScottGu's Blog&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;&lt;a href="http://www.hanselman.com/blog/" target="_blank"&gt;Scott Hanselmann's Blog&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;&lt;a href="http://asp.net" target="_blank"&gt;The official ASP.NET site&lt;/a&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Get familiar with the newer .NET technology. &lt;a href="http://www.asp.net/LEARN/linq-videos/" target="_blank"&gt;LINQ&lt;/a&gt;, &lt;a href="http://www.asp.net/dynamicdata/" target="_blank"&gt;Dynamic Data&lt;/a&gt;, and recently released &lt;a href="http://www.asp.net/mvc/" target="_blank"&gt;ASP.NET MVC&lt;/a&gt;, are all three extremely powerful ways to make high-powered web sites fast. You can literally build an admin panel interface in minutes with a database using Dynamic Data because it will automatically generate scaffolding (you'll learn) and the forms for you. It's just like PHP: if you want to be awesome you'll need to learn some kind of framework whether it's Ruby on Rails, Drupal, CakePHP, or others. &lt;/li&gt;    &lt;li&gt;Look into source code versioning systems like SVN, CVS, and others. Personally, I use the &lt;a href="http://ankhsvn.open.collab.net/" target="_blank"&gt;AnkhSVN plug-in for Visual Studio&lt;/a&gt; and TortoiseSVN for my source code repositories. It can come in handy when you want to keep track of your changes, back-up your code, or start doing team development. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Whether you use PHP or .NET I would highly recommend learning about the MVC design pattern and 3/n-tier architecture (they are &lt;a href="http://forums.asp.net/p/1020216/1379168.aspx" target="_blank"&gt;different&lt;/a&gt;). If you work in the web environment you will likely come across these terms a lot. &lt;/p&gt;  &lt;p&gt;In the end it's up to you. I've been doing .NET development for about 6-7 years now and the past 4 years I've been learning PHP where I work. It really helps with my freelance work because I can do everything from quick small PHP sites to large .NET-driven sites. Sometimes I find myself hating PHP for making me do form logic and other times I hate .NET for not having some of the powerful PHP array functions. &lt;/p&gt;  &lt;p&gt;Good luck on your future web endeavors!&lt;/p&gt;</description>
      <pubDate>Fri, 24 Apr 2009 15:58:55 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-56</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/4u9jNL4Txv8/beginning-dot-net-development.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/4/24/beginning-dot-net-development.aspx</feedburner:origLink></item>
    <item>
      <title>Simple ToolTips for ListBox Controls [Windows Forms]</title>
      <description>&lt;p&gt;I am working on a project right now and I list values in a &lt;var&gt;ListBox&lt;/var&gt;, but the text gets cut off when a value is really long. I looked around and while I found custom controls and such, I didn't need anything fancy. Here is a quick fix I found on MSDN.&lt;/p&gt;  &lt;p&gt;I am assuming you've added a &lt;var&gt;ToolTip&lt;/var&gt; control named MyToolTip to the form and the name of your &lt;var&gt;ListBox&lt;/var&gt; is MyListBox.&lt;/p&gt;  &lt;pre class="vb" name="code"&gt;    
    Private Sub MyListBox_MouseMove(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.MouseEventArgs) _
        Handles MyListBox.MouseMove
        If TypeOf sender Is ListBox Then
            Dim lst As ListBox = DirectCast(sender, ListBox)
            Dim point As New Point(e.X, e.Y)
            Dim hoverIndex As Integer = lst.IndexFromPoint(point)

            If hoverIndex &amp;gt;= 0 AndAlso hoverIndex &amp;lt; lst.Items.Count Then
                MyToolTip.SetToolTip(lst, lst.Items(hoverIndex).ToString)
            End If
        End If
    End Sub&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Thanks to Jesse Bolatto on the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox(VS.85).aspx" target="_blank"&gt;ListBox MSDN article&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 09 Apr 2009 21:41:11 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-55</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/rDbYg9X2N_4/simple-tooltips-for-listbox-controls-windows.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/4/9/simple-tooltips-for-listbox-controls-windows.aspx</feedburner:origLink></item>
    <item>
      <title>Fix IE iFrame Disabled Scrollbar Render Bug [CSS]</title>
      <description>&lt;p&gt;In a project I'm currently working on, we have content pop up in ShadowBox from another page. The problem was that in Internet Explorer, a space on the right side of the iframe was appearing that made my background picture on the &lt;var&gt;body&lt;/var&gt; tag and a &lt;var&gt;div&lt;/var&gt; tag not line up.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.intrepidstudios.com/blog/images/CSSFixIEiFrameDisabledScrollBarRenderBug_DA6D/image.png"&gt;&lt;img style="display: inline" title="image" alt="image" src="http://www.intrepidstudios.com/blog/images/CSSFixIEiFrameDisabledScrollBarRenderBug_DA6D/image_thumb.png" width="520" height="145" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I found out that it has to do with the scrollbar. If you resize the page, you can see that the space gets filled up by the vertical scrollbar.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.intrepidstudios.com/blog/images/CSSFixIEiFrameDisabledScrollBarRenderBug_DA6D/image_3.png"&gt;&lt;img style="display: inline" title="image" alt="image" src="http://www.intrepidstudios.com/blog/images/CSSFixIEiFrameDisabledScrollBarRenderBug_DA6D/image_thumb_3.png" width="520" height="71" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So how do you fix it? It's simple.&lt;/p&gt;  &lt;p&gt;Add &lt;code&gt;overflow:auto&lt;/code&gt; to the &lt;var&gt;body&lt;/var&gt; tag in your CSS.&lt;/p&gt;  &lt;pre class="css" name="code"&gt;body {
	overflow:auto;
}&lt;/pre&gt;

&lt;p&gt;And voila! It's fixed:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.intrepidstudios.com/blog/images/CSSFixIEiFrameDisabledScrollBarRenderBug_DA6D/image_4.png"&gt;&lt;img style="display: inline" title="image" alt="image" src="http://www.intrepidstudios.com/blog/images/CSSFixIEiFrameDisabledScrollBarRenderBug_DA6D/image_thumb_4.png" width="520" height="67" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Stupid IE.&lt;/p&gt;

&lt;p&gt;Thanks to Keith Bucklen via &lt;a href="http://www.trap17.com/index.php/css-trick-hide-disabled-internet-explorer-vertical-scrollbar_t20688.html" target="_blank"&gt;Css Trick: Hide Disabled Internet Explorer Vertical Scrollbar&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 24 Mar 2009 20:39:41 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-54</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/_yih2NI2DYY/fix-ie-iframe-disabled-scrollbar-render-bug-c.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/3/24/fix-ie-iframe-disabled-scrollbar-render-bug-c.aspx</feedburner:origLink></item>
    <item>
      <title>New Sample Solutions Section Added: Arrays, Datasets, and BlackJack [Content]</title>
      <description>&lt;p&gt;&lt;a href="http://intrepidstudios.com/projects/samples/"&gt;&lt;img style="display: inline" title="simple-blackjack" alt="simple-blackjack" src="http://www.intrepidstudios.com/blog/images/NewSampleSolutionsSectionAddedArraysData_CE69/simpleblackjack.gif" width="520" height="386" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We've created a new section as part of our Projects area for all of our &lt;a href="http://www.intrepidstudios.com/projects/samples/" target="_blank"&gt;sample applications and code&lt;/a&gt;. Before, we'd upload a zip into a public folder and forget about it. Now we can properly manage releases and have additional information for samples.&lt;/p&gt;  &lt;p&gt;Today we added:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;BlackJack:&lt;/strong&gt; A simple VB.NET implementation for BlackJack. We actually have a newer iteration of this sample that implements Windows Presentation Foundation (WPF) but we are holding off on posting that until it's ready to be distributed (soon). &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Strongly-typed Dataset:&lt;/strong&gt; A sample program using a gradebook that showcases how to use a strongly-typed dataset with Microsoft Access to simplify CRUD operations. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Multi-dimensional Arrays:&lt;/strong&gt; A sample program using an airline reservation system to show how to use multi-dimensional arrays and create a seating chart. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The above samples were actually created for a class and I've posted the last two before on my personal blog. The BlackJack game was ready to package so I decided to post it as a sample since it's so stripped down.&lt;/p&gt;  &lt;p&gt;Stay tuned for more samples as we get them ready for distribution.&lt;/p&gt;</description>
      <pubDate>Fri, 06 Mar 2009 20:43:57 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-53</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/q-T7Wkv0JBc/new-sample-solutions-section-added.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/3/6/new-sample-solutions-section-added.aspx</feedburner:origLink></item>
    <item>
      <title>Release: Image Grid Creator [Windows]</title>
      <description>&lt;p&gt;&lt;a href="http://intrepidstudios.com/projects/grid-creator" target="_blank"&gt;&lt;img style="display: inline" title="album_grid_creator" alt="album_grid_creator" src="http://www.intrepidstudios.com/blog/images/AlbumCoverGridCreator.NET_CC00/album_grid_creator_thumb.png" width="184" height="184" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This is not a new software we've created, instead we've created a project homepage for the &lt;a href="http://intrepidstudios.com/projects/grid-creator" target="_blank"&gt;Image Grid Creator&lt;/a&gt; (formerly known as Album Grid Creator). The software was originally released before the Intrepid Studios web site was finished but I updated it today to support some more file formats.&lt;/p&gt;  &lt;p&gt;The Image Grid Creator will take a folder of images and create a grid out of them according to your specifications.&lt;/p&gt;  &lt;h4&gt;Download&lt;/h4&gt;  &lt;p&gt;To download the software, head on over to the &lt;a href="http://intrepidstudios.com/projects/grid-creator" target="_blank"&gt;Image Grid Creator&lt;/a&gt; project homepage.&lt;/p&gt;</description>
      <pubDate>Thu, 05 Mar 2009 15:43:08 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-52</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/Kv6iBAU20SM/release-image-grid-creator-windows.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/3/5/release-image-grid-creator-windows.aspx</feedburner:origLink></item>
    <item>
      <title>Putting DynamicFields in a Validation Group [Dynamic Data]</title>
      <description>&lt;p&gt;If you're like me, you've implemented Dynamic Data with master-detail pages that include GridView controls and perhaps multiple drill-down DetailsView controls or other form controls.&lt;/p&gt;  &lt;p&gt;You also proceeded to realize that validating two or more controls on the same page with DynamicFields is hard, to the say the least. Luckily, I found a streamlined solution!&lt;/p&gt;  &lt;p&gt;Before I point out the solution, I have to say, &amp;quot;Thanks!&amp;quot; to the great folks at Microsoft for actually bothering to help me with my lowly requests. &lt;/p&gt;  &lt;p&gt;Earlier I asked &lt;a href="http://weblogs.asp.net/Scottgu/" target="_blank"&gt;Scott Guthrie&lt;/a&gt; about my &lt;a href="http://www.intrepidstudios.com/blog/2009/2/25/url-rewrite-not-working-use-iis7-integrated-m.aspx" target="_blank"&gt;problems with URL rewriting&lt;/a&gt; and now one of members of the Dynamic Data team, Scott Hunter, actually said because many users are requesting it that the team is &lt;strong&gt;implementing validation groups for DynamicFields in the next release&lt;/strong&gt;. Whoo!&lt;/p&gt;  &lt;p&gt;Until the next version, Scott pointed out &lt;a href="http://forums.asp.net/p/1288300/2877388.aspx" target="_blank"&gt;this asp.net thread&lt;/a&gt; for the solution (at the end). &lt;/p&gt;  &lt;p&gt;Here it is, simple and easy:&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;namespace JJ.Controls
{
   public class ValidationGroupDynamicField: DynamicField
    {

        private string _validationGroup;
        public string ValidationGroup
        {
            get
            {
                return _validationGroup;
            }
            set
            {
                _validationGroup = value;
            }
        }

        public override void InitializeCell(
        System.Web.UI.WebControls.DataControlFieldCell cell, 
        System.Web.UI.WebControls.DataControlCellType cellType, 
        System.Web.UI.WebControls.DataControlRowState rowState, 
        int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);

            if (cellType == DataControlCellType.DataCell)
            {
                if (ValidationGroup != null)
                    ((DynamicControl)cell.Controls[0]).ValidationGroup
                         = ValidationGroup;
            }
        }
    }
}&lt;/pre&gt;

&lt;p&gt;Then, register the namespace in your ASPX file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;%@ Register Assembly=&amp;quot;CustomControls&amp;quot; Namespace=&amp;quot;JJ.Controls&amp;quot; TagPrefix=&amp;quot;jj&amp;quot; %&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, in your ASPX file:&lt;/p&gt;

&lt;pre&gt;&amp;lt;Fields&amp;gt;
    &amp;lt;jj:ValidationGroupDynamicField DataField=&amp;quot;Url&amp;quot; 
           ValidationGroup=&amp;quot;myGroup&amp;quot; /&amp;gt;
&amp;lt;/Fields&amp;gt;&lt;/pre&gt;

&lt;p&gt;Thank you to Scott Hunter and &lt;a href="http://forums.asp.net/members/javan15.aspx"&gt;javan15&lt;/a&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;for the solution!&lt;/p&gt;</description>
      <pubDate>Thu, 26 Feb 2009 01:13:21 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-51</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/bSPF-xuwbCM/putting-dynamicfields-in-a-validation-group-d.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/26/putting-dynamicfields-in-a-validation-group-d.aspx</feedburner:origLink></item>
    <item>
      <title>URL Rewrite Not Working? Use IIS7 Integrated Mode</title>
      <description>&lt;p&gt;Recently for our web site, we ran into a problem where our URL rewrite module wasn't working with non-.NET-handled files. As you may know, IIS7 &lt;strong&gt;supports&lt;/strong&gt; using URL rewriting with all kinds of files without too much web.config editing.&lt;/p&gt;  &lt;p&gt;The solution was simple: our host did not set our web site to Integrated Mode in IIS7. Once they did, all of our rules were working.&lt;/p&gt;  &lt;p&gt;For more information about IIS7 settings, take a look at this post:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/"&gt;Wildcard script mapping and IIS 7 integrated pipeline&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 25 Feb 2009 16:17:45 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-50</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/iWn_mpLu0lc/url-rewrite-not-working-use-iis7-integrated-m.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/25/url-rewrite-not-working-use-iis7-integrated-m.aspx</feedburner:origLink></item>
    <item>
      <title>Function That Generates a Page Title Based Off Web.Sitemap [Helpers]</title>
      <description>&lt;p&gt;On the Intrepid Studios site, we use a web.sitemap file to keep a list of the static pages on the site. It's becoming more common in web design to have a page title that is a reverse-breadcrumb.&lt;/p&gt;  &lt;p&gt;Here is a helper function that we use to generate page titles automatically based off the web.sitemap. If the page does not exist in the sitemap, it will take the title from the &lt;code&gt;Page.Title&lt;/code&gt; attribute given in the page.&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;    
    public static string GeneratePageTitle(string title, 
                                           string rootTitle, 
                                           string pathSeparator)
    {

        List&amp;lt;string&amp;gt; path = new List&amp;lt;string&amp;gt;();
        SiteMapNode currentNode = null;

        currentNode = SiteMap.CurrentNode;

        if (currentNode == null)
        {
            if (String.IsNullOrEmpty(title))
            {
                return rootTitle;
            }

            return title + pathSeparator + rootTitle;
        }

        if (currentNode != SiteMap.RootNode)
        {
            if (!String.IsNullOrEmpty(title) &amp;amp;&amp;amp; title != rootTitle)
            {
                path.Add(title);
            }
            else
            {
                path.Add(currentNode.Title);
            }
        }
        else
        {
            path.Add(rootTitle);
        }

        currentNode = currentNode.ParentNode;

        while (!(currentNode == null))
        {

            // Use our own root title for the &amp;lt;title&amp;gt; tag
            if (currentNode.Title != SiteMap.RootNode.Title)
            {
                path.Add(currentNode.Title);
            }
            else
            {
                path.Add(rootTitle);
            }

            currentNode = currentNode.ParentNode;
        }

        string[] paths = path.ToArray();

        return string.Join(pathSeparator, paths);

    }&lt;/pre&gt;

&lt;p&gt;You can use it like this in the code-behind, probably in your master template:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Page.Title = Helpers.GeneratePageTitle(Page.Title, &amp;quot;My Base Title&amp;quot;, &amp;quot; | &amp;quot;);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In your page, make sure to set the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;head runat=&amp;quot;server&amp;quot;&amp;gt;&lt;/code&gt; which is what it defaults to typically anyway, otherwise .NET will not alter the title tag appropriately.&lt;/p&gt;

&lt;p&gt;Feel free to modify it to your needs.&lt;/p&gt;

&lt;p&gt;This function works with URL rewriting (see this blog post's title?), because you can assign the &lt;code&gt;Page.Title&lt;/code&gt; property programmatically in the code-behind. Technically I also dynamically modify the sitemap, but that's for another day.&lt;/p&gt;</description>
      <pubDate>Sat, 14 Feb 2009 17:51:32 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-48</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/5fPDNYHM8Y8/function-that-generates-a-page-title-based-of.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/14/function-that-generates-a-page-title-based-of.aspx</feedburner:origLink></item>
    <item>
      <title>Function That Resizes Dimensions to Bounds [Helpers]</title>
      <description>&lt;p&gt;In one of my current projects at work I needed to load photos off the file system and resize them so that they fit within a specified set of bounds. So, obviously, I created a function to calculate it for me!&lt;/p&gt;  &lt;p&gt;I also use an equivalent function for Intrepid Studios, which is provided after the PHP function.&lt;/p&gt;  &lt;pre class="php" name="code"&gt;/**
 *  Summary:
 *  	Gets a new size that fits within
 *  	a set bounds.
 *  	Pass in false/null if you do not want bounds
 *  	on a specific axis.
 *  Parameters:
 *     	- mw : Max Width
 *     	- mh : Max Height
 *     	- ow : Original Width
 *     	- oh : Original Height
 *  Returns:
 *      array['w'] : new width
 *      array['h'] : new height
 */
function sizeToBounds($mw, $mh, $ow, $oh) {
	$returnSize = array(&amp;quot;w&amp;quot; =&amp;gt; 0, &amp;quot;h&amp;quot; =&amp;gt; 0);
	
	// Vars
	$w = $ow;
	$h = $oh;
	$wr = $w / $mw;  // w ratio
	$hr = $h / $mh; // h ratio
	
	// First size its width
	if($mw &amp;amp;&amp;amp; $w &amp;gt; $mw) {						
		// Set width
		$w = $mw;
		$h = intval($h / $wr);
	}
	
	// Then its height
	if($mh &amp;amp;&amp;amp; $h &amp;gt; $mh) {						
		// Set width
		$w = intval($w / $hr);
		$h = $mh;
	}
	
	$returnSize['w'] = $w;
	$returnSize['h'] = $h;
	
	return $returnSize;
}&lt;/pre&gt;

&lt;p&gt;Use it like so:&lt;/p&gt;

&lt;pre class="php" name="code"&gt;$newSize = sizeToBounds(200, 200, 230, 435);

echo (&amp;quot;w = &amp;quot; . $newSize['w'] . &amp;quot;, h = &amp;quot; . $newSize['h']);

// outputs
w = 91, h = 200&lt;/pre&gt;

&lt;p&gt;And the C# equivalent function:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;// import System.Drawing

public static Size sizeToBounds(int mw, int mh, int nw, int nh)
    {
        double wr, hr;

        // Scales image to bounds
        wr = (double)nw / (double)mw;
        hr = (double)nh / (double)mh;

        // First width
        if (mw != 0 &amp;amp;&amp;amp; nw &amp;gt; mw)
        {
            nw = mw;
            nh = (int)(nh / wr);
        }

        // Then, height
        if (mh != 0 &amp;amp;&amp;amp; nh &amp;gt; mh)
        {
            nh = mh;
            nw = (int)(nw / hr);
        }

        return new Size(nw, nh);
    }&lt;/pre&gt;

&lt;p&gt;Use it like so:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;Size NewSize = sizeToBounds(200, 200, 230, 435);

Response.Write(&amp;quot;w = &amp;quot; + NewSize.Width + &amp;quot;, h = &amp;quot; + NewSize.Height);

// outputs
w = 91, h = 200&lt;/pre&gt;

&lt;p&gt;How about a function that will just do everything for you? This PHP function will find the appropriate resized width and height for a photo on the file system.&lt;/p&gt;

&lt;pre class="php" name="code"&gt;/**
 * Gets the new size for a photo,
 * fit within a set xy bounds.
 */
function sizePhotoToBounds($mw, $mh, $img) {
	if(!file_exists($img)) {
		return false;
	}
		
	$s = getimagesize($img);

	// Failed, no width, or no height
	if(!$s || $s[0] == 0 || $s[1] == 0 ) {
	
		return false;
	
	} else {			
	
		// Everything's hunky dory		
		return sizeToBounds($mw, $mh, $s[0], $s[1]);
	}
}&lt;/pre&gt;

&lt;p&gt;&lt;var&gt;$img&lt;/var&gt; refers to the full path to the image file.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;</description>
      <pubDate>Thu, 12 Feb 2009 20:01:10 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-47</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/xpMdFd82ayA/function-that-resizes-dimensions-to-bounds-he.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/12/function-that-resizes-dimensions-to-bounds-he.aspx</feedburner:origLink></item>
    <item>
      <title>PHP String Format Function [Helpers]</title>
      <description>&lt;p&gt;In .NET we have a great little function called &lt;code&gt;String.Format&lt;/code&gt; that will transform a string and format it. For example, let's say I wanted to display the phrase &amp;quot;Posted at: Wed Jan 5, 2009.&amp;quot; Typically you would write:&lt;/p&gt;  &lt;p&gt;&lt;code&gt;str = &amp;quot;Posted at: &amp;quot; + aDate.ToString(&amp;quot;ddd MMM d, yyyy&amp;quot;); &lt;/code&gt;&lt;/p&gt;  &lt;p&gt;Instead, &lt;code&gt;String.Format&lt;/code&gt; lets you do:&lt;/p&gt;  &lt;p&gt;&lt;code&gt;str = String.Format(&amp;quot;Posted at: {0:ddd MM d, yyyy}&amp;quot;, aDate); &lt;/code&gt;&lt;/p&gt;  &lt;p&gt;Imagine a phrase that had a lot of things that needed to be formatted or concatenated, you'll find &lt;code&gt;String.Format&lt;/code&gt; is pretty nice.&lt;/p&gt;  &lt;p&gt;In PHP there isn't really a function like that, you're stuck with concatenating them. Usually that's fine, but for those of you that want to store substitutable strings in a database, or just have lots of strings to concatenate, you can use this.&lt;/p&gt;  &lt;p&gt;It does &lt;strong&gt;not&lt;/strong&gt; format dates, etc. (yet) like .NET, it only substitutes strings.&lt;/p&gt;  &lt;pre class="php" name="code"&gt;/**
  * Formats a string with zero-based placeholders
  * {0}, {1} etc corresponding to an array of arguments
  * Must pass in a string and 1 or more arguments
  */
function string_format($str) {
	// replaces str &amp;quot;Hello {0}, {1}, {0}&amp;quot; with strings, based on
	// index in array
	$numArgs = func_num_args() - 1;
	
	if($numArgs &amp;gt; 0) {
		$arg_list = array_slice(func_get_args(), 1);
		
		// start after $str
		for($i=0; $i &amp;lt; $numArgs; $i++) {
			$str = str_replace(&amp;quot;{&amp;quot; . $i . &amp;quot;}&amp;quot;, $arg_list[$i], $str);
		}
	}

	return $str;
}&lt;/pre&gt;

&lt;p&gt;Use it like so:&lt;/p&gt;

&lt;pre class="php" name="code"&gt;$phrase = &amp;quot;Apples: {0}, Oranges: {1}, Grapes: {2}, Apple/Orange Ratio: {0}/{1}&amp;quot;;

echo string_format($phrase, 5, 6, 7);

// outputs
Apples: 5, Oranges: 6, Grapes: 7, Apple/Orange Ratio: 5/6&lt;/pre&gt;

&lt;p&gt;PHP also has a function called &lt;a href="http://us.php.net/sprintf" target="_blank"&gt;sprintf&lt;/a&gt;, which you can look into for your needs as well. It is a bit more strict, I am not sure whether you will run into type mismatches (example, using '%s' and passing in an integer). You &lt;em&gt;can&lt;/em&gt; repeat placeholders and format them. The function above might be friendlier to .NET'rs using PHP and will substitute anything as it just performs a replace operation.&lt;/p&gt;</description>
      <pubDate>Wed, 11 Feb 2009 20:50:33 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-46</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/nRh99raC5l0/php-string-format-function.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/11/php-string-format-function.aspx</feedburner:origLink></item>
    <item>
      <title>Function to Generate a Slug (URL-friendly String) [Helpers]</title>
      <description>&lt;p&gt;&lt;strong&gt;Update #1:&lt;/strong&gt; With the help of my esteemed colleague &lt;a href="http://zachstronaut.com" target="_blank"&gt;Zach&lt;/a&gt;, I've provided a PHP function as well and fixed some bugs with the .NET version.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Update #2:&lt;/strong&gt; Added the &amp;quot;-&amp;quot; character to the non-invalid chars list so passing in an already-generated slug didn't break it.&lt;/p&gt;  &lt;p&gt;The term &amp;quot;slug&amp;quot; was first coined, I believe, by Wordpress to mean a URL-friendly version of a post title. From their codex:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;A &lt;b&gt;slug&lt;/b&gt; is a few words that describe a post or a page. Slugs are usually a URL friendly version of the post title (which has been automatically generated by WordPress), but a slug can be anything you like. Slugs are meant to be used with &lt;a href="http://codex.wordpress.org/Glossary#Permalink"&gt;permalinks&lt;/a&gt; as they help describe what the content at the URL is.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;How do you go about converting an unfriendly title into a friendly one?&lt;/p&gt;  &lt;p&gt;Here's a helper function that does just that:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;    public static string GenerateSlug(string phrase)
    {
        string str = phrase.ToLower();

        str = Regex.Replace(str, @&amp;quot;[^a-z0-9\s-]&amp;quot;, &amp;quot;&amp;quot;); // invalid chars        
        str = Regex.Replace(str, @&amp;quot;\s+&amp;quot;, &amp;quot; &amp;quot;).Trim(); // convert multiple spaces into one space
        str = str.Substring(0, str.Length &amp;lt;= 45 ? str.Length : 45).Trim(); // cut and trim it
        str = Regex.Replace(str, @&amp;quot;\s&amp;quot;, &amp;quot;-&amp;quot;); // hyphens

        return str;
    }&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;In PHP:&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="php" name="code"&gt;function generateSlug($phrase)
{
    $result = strtolower($phrase);

    $result = preg_replace(&amp;quot;/[^a-z0-9\s-]/&amp;quot;, &amp;quot;&amp;quot;, $result);
    $result = trim(preg_replace(&amp;quot;/\s+/&amp;quot;, &amp;quot; &amp;quot;, $result));
    $result = trim(substr($result, 0, 45));
    $result = preg_replace(&amp;quot;/\s/&amp;quot;, &amp;quot;-&amp;quot;, $result);

    return $result;
}&lt;/pre&gt;

&lt;p&gt;What is it doing?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Transform string into lowercase &lt;/li&gt;

  &lt;li&gt;Remove invalid characters (not alphanumeric or spaces) &lt;/li&gt;

  &lt;li&gt;Trim and convert multiple spaces into only one space, to get the best string. &lt;/li&gt;

  &lt;li&gt;Extract first 45 characters then trim spaces (in case the 45th char is a space) &lt;/li&gt;

  &lt;li&gt;Transform spaces into a hyphens. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can add on features, like changing common symbols into words, like &amp;quot;.&amp;quot; into &amp;quot;dot&amp;quot; and so on. &lt;/p&gt;

&lt;p&gt;Why a max of 45? In my DB I have the column set to a max length of 50 and in the future I may implement some sort of duplicate checking and append numbers at the end of the title. Also, I think 50 characters is a good enough length for someone to type in.&lt;/p&gt;

&lt;p&gt;Here's how to use it:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;// slug
string title = @&amp;quot;A bunch of ()/*++\'#@$&amp;amp;*^!%     invalid URL characters  &amp;quot;;

lblSlug.Text = GenerateSlug(title);

// outputs
a-bunch-of-invalid-url-characters&lt;/pre&gt;

&lt;pre class="php" name="code"&gt;$title = &amp;quot;A bunch of ()/*++\'#@$&amp;amp;*^!%     invalid URL characters  &amp;quot;;

echo(generateSlug($title));

// outputs
a-bunch-of-invalid-url-characters&lt;/pre&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;</description>
      <pubDate>Tue, 10 Feb 2009 17:17:41 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-45</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/zIHxJd5AwZM/function-to-generate-a-url-friendly-string.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/10/function-to-generate-a-url-friendly-string.aspx</feedburner:origLink></item>
    <item>
      <title>Using Default Values in LINQ to SQL</title>
      <description>&lt;p&gt;If your SQL Server automatically provides default values for certain columns, you may be scratching your head wondering why Linq to SQL throws errors when you don't provide values for those columns whenever you insert rows.&lt;/p&gt;  &lt;p&gt;It seems like a simple fix and luckily it is, albeit a bit buried in forum threads. Contrary to what you might think, if you want to change that column in your code (the majority of the columns you probably have), you &lt;strong&gt;cannot&lt;/strong&gt; set &lt;em&gt;Auto Generated Value&lt;/em&gt; to &lt;strong&gt;true&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;As far as I understand, &lt;em&gt;Auto Generated Value&lt;/em&gt; refers to a calculated column and so Linq to SQL will prevent you from editing it or changing it.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The key is to set &lt;strong&gt;Auto-Sync&lt;/strong&gt; to either &lt;u&gt;OnInsert&lt;/u&gt;, &lt;u&gt;OnUpdate&lt;/u&gt;, or &lt;u&gt;Always&lt;/u&gt;.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;If you have a column that has a default value which you do not want the program to modify:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.intrepidstudios.com/blog/images/UsingDefaultValuesinLINQtoSQL_EDDB/db_readonly_default_value.png"&gt;&lt;img style="display: inline" title="db_readonly_default_value" alt="db_readonly_default_value" src="http://www.intrepidstudios.com/blog/images/UsingDefaultValuesinLINQtoSQL_EDDB/db_readonly_default_value_thumb.png" width="308" height="218" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;(&lt;em&gt;Note:&lt;/em&gt; I think only setting&lt;em&gt; Read Only&lt;/em&gt; to &lt;strong&gt;True&lt;/strong&gt; should be fine instead of also changing &lt;em&gt;Auto Generated Value&lt;/em&gt; but I haven't tested it.)&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;If you have a column that needs a default value on Insert only and you update it throughout your application:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.intrepidstudios.com/blog/images/UsingDefaultValuesinLINQtoSQL_EDDB/db_insert_default_value.png"&gt;&lt;img style="display: inline" title="db_insert_default_value" alt="db_insert_default_value" src="http://www.intrepidstudios.com/blog/images/UsingDefaultValuesinLINQtoSQL_EDDB/db_insert_default_value_thumb.png" width="306" height="276" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can play with Auto-Sync to get what you want, but that's how Linq to SQL takes care of Default Values.&lt;/p&gt;  &lt;p&gt;In code-behind, the three attributes look like this:&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;[Column(AutoSync=AutoSync.OnInsert,
            IsDbGenerated=true)]
[ReadOnly]
public DateTime Created
{
}&lt;/pre&gt;</description>
      <pubDate>Fri, 06 Feb 2009 23:04:30 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-43</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/sD80W3Qt0gg/using-default-values-in-linq-to-sql.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/6/using-default-values-in-linq-to-sql.aspx</feedburner:origLink></item>
    <item>
      <title>Hamster Malfunctions [Buggy]</title>
      <description>&lt;p&gt;Please forgive us if you encounter errors while browsing the site. We are constantly working on it and when transferring files over we sometimes miss ones. The errors should go away after a few minutes.&lt;/p&gt;  &lt;p&gt;We're also working on an error reporting system so if there &lt;em&gt;are&lt;/em&gt; errors that don't go away, we'll know about it. Assuming email isn't the problem.&lt;/p&gt;  &lt;p&gt;We do have a test site and we use that for major updates but for small updates we just go live because it works on our development server and it works on the live server, when we upload the right files.&lt;/p&gt;  &lt;p&gt;It's times like these I wish Visual Studio had a better Publish feature that wouldn't take 4 hours publishing to FTP. Why can't it work smoothly like Dreamweaver?&lt;/p&gt;  &lt;p&gt;I am taking a Systems Analysis class right now and we were talking about the differences between the Waterfall method, the Rapid Application Development method, and the Agile Development method, and as you can maybe tell, I am using an approach between RAD and the Agile method because I tend to churn out bug fixes once or more a day but soon iterative development will slow down as the site becomes fully functional. I keep a running to-do list in an Excel sheet so I can note features/bugs/suggestions I find or receive for later fixing/implementing. So while RAD/Agile let me release the new Intrepid Studio site sooner it also brought with it a slew of bugs or features that weren't visible on the surface.&lt;/p&gt;  &lt;p&gt;I agree with my professor when she notes that no &lt;strong&gt;one&lt;/strong&gt; of them is the &lt;em&gt;best&lt;/em&gt; method, they all have ups and downs.&lt;/p&gt;</description>
      <pubDate>Thu, 05 Feb 2009 06:10:59 GMT</pubDate>
      <guid isPermaLink="false">ISBlog-40</guid>
      <link>http://feedproxy.google.com/~r/IntrepidStudios/~3/tSpUEnKKBuA/hamster-malfunctions-and-bugs.aspx</link>
    <feedburner:origLink>http://www.intrepidstudios.com/blog/2009/2/5/hamster-malfunctions-and-bugs.aspx</feedburner:origLink></item>
  </channel>
</rss>
