<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Ryan Ternier </title><subtitle type="html">Killer ASP.NET ninja coding monkeys do exist!</subtitle><id>http://weblogs.asp.net/rternier/atom.aspx</id><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/default.aspx" /><link rel="self" type="application/atom+xml" href="http://weblogs.asp.net/rternier/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2008-01-31T10:04:00Z</updated><entry><title>JQuery image Upload &amp; refresh using an ASHX File part 2.</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2010/09/17/jquery-image-upload-amp-refresh-using-an-ashx-file-part-2.aspx" /><id>http://weblogs.asp.net/rternier/archive/2010/09/17/jquery-image-upload-amp-refresh-using-an-ashx-file-part-2.aspx</id><published>2010-09-17T17:17:00Z</published><updated>2010-09-17T17:17:00Z</updated><content type="html">&lt;p&gt;A bit ago I wrote a blog post about how to hook up a JQuery upload script go a page to asynchronously upload files to an ASHX page on a server.&lt;/p&gt;

&lt;p&gt;For the 2nd part I’ll show you an easy snippet of code that can be used to upload and/or view the image. The example below deals with signatures, though it can be easily and quickly modified for any type of image.&lt;/p&gt;

&lt;p&gt;I’m storing the uploaded image in a Session variable. I do this because a user might have uploaded a wrong image or they might not want to save what they uploaded. As well, once you upload an image to the server, you are going to want to let the user see it. If the image was incorrect, you’ll be writing it to the database and then retrieving it back right away, not really efficient.&lt;/p&gt;

&lt;p&gt;Remember to include the IRequiresSessionState interface when you are creating your ASHX class so you have access to the Session.&lt;/p&gt;

&lt;p&gt;Let’s look at some code. I have to determine what I’m doing – uploading an image, or viewing one.&lt;/p&gt;

&lt;h3&gt;Upload&lt;/h3&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5e0b0907-5d4d-412d-b3ae-110b237bf5cd" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px; white-space: nowrap"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; fileName = System.IO.&lt;span style="color:#2b91af"&gt;Path&lt;/span&gt;.GetFileName(context.Request.Files[0].FileName);&lt;br&gt;
&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; extention = System.IO.&lt;span style="color:#2b91af"&gt;Path&lt;/span&gt;.GetExtension(context.Request.Files[0].FileName).ToLower();&lt;br&gt;
&lt;span style="color:#2b91af"&gt;HttpPostedFile&lt;/span&gt; file = context.Request.Files[0];&lt;br&gt;
&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (file.ContentLength == 0)&lt;br&gt;
{&lt;br&gt;
    &lt;span style="color:#008000"&gt;//no file posted.&lt;/span&gt;&lt;br&gt;
    rMessage = &lt;span style="color:#a31515"&gt;&amp;quot;There was no data found in the file. Please ensure the file being uploaded is a valid image file.&amp;quot;&lt;/span&gt;;&lt;br&gt;
    &lt;span style="color:#0000ff"&gt;break&lt;/span&gt;;&lt;br&gt;
}&lt;br&gt;
&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;[] bImage = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Byte&lt;/span&gt;[file.ContentLength];&lt;br&gt;
file.InputStream.Read(bImage, 0, file.ContentLength);&lt;br&gt;
context.Session[&lt;span style="color:#a31515"&gt;&amp;quot;Signature&amp;quot;&lt;/span&gt;] = bImage;&lt;br&gt;
&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (info.Successful)&lt;br&gt;
{&lt;br&gt;
    rMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Signature upload successful.&amp;quot;&lt;/span&gt;;&lt;br&gt;
}&lt;br&gt;
&lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;br&gt;
{&lt;br&gt;
    rMessage = &lt;span style="color:#a31515"&gt;&amp;quot;There was an error uploading your signature.&amp;quot;&lt;/span&gt;;&lt;br&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;All files that are uploaded are located in context.Request.Files. Seeing I’m only uploading one image, I know it’s going to be at the 0 index in the FileCollection.&lt;/p&gt;

&lt;p&gt;Once I have my file, I want to create a byte array (byte[]) of that file, and store that in memory.&lt;/p&gt;

&lt;p&gt;And we’re done.&lt;/p&gt;

&lt;h3&gt;View&lt;/h3&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b636213-6ef3-4aef-96c0-6aefc2b7b5eb" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px; white-space: nowrap"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; contentType = Microsoft.Win32.&lt;span style="color:#2b91af"&gt;Registry&lt;/span&gt;.GetValue(&lt;span style="color:#a31515"&gt;&amp;quot;HKEY_CLASSES_ROOT&amp;#92;&amp;#92;.PNG&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;Content Type&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;application/octetstream&amp;quot;&lt;/span&gt;).ToString();&lt;br&gt;
utility = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Utility&lt;/span&gt;();&lt;br&gt;
&lt;span style="color:#0000ff"&gt;double&lt;/span&gt; scale = utility.GetScale(signature, 450, 50);&lt;br&gt;
signature = utility.ScaleByPercent(signature, (&lt;span style="color:#0000ff"&gt;float&lt;/span&gt;)scale);&lt;br&gt;
                &lt;br&gt;
context.Response.AddHeader(&lt;span style="color:#a31515"&gt;&amp;quot;Content-Disposition&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;attachment; filename=UserSignature.png&amp;quot;&lt;/span&gt;);&lt;br&gt;
context.Response.AddHeader(&lt;span style="color:#a31515"&gt;&amp;quot;Content-Length&amp;quot;&lt;/span&gt;, signature.Length.ToString());&lt;br&gt;
context.Response.AddHeader(&lt;span style="color:#a31515"&gt;&amp;quot;Cache-Control&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;no-cache, must-revalidate&amp;quot;&lt;/span&gt;);&lt;br&gt;
context.Response.Expires = -1;&lt;br&gt;
context.Response.ContentType = contentType;                &lt;br&gt;
context.Response.BufferOutput = &lt;span style="color:#0000ff"&gt;false&lt;/span&gt;;                &lt;br&gt;
context.Response.OutputStream.Write(signature, 0, signature.Length);&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;After I upload an image I change the SRC of my &amp;lt;img /&amp;gt; control so it will download the new image. I do this by adding a randomized alpha-numeric string to the end so the browser will not cache the image.&lt;/p&gt;

&lt;p&gt;In this example I’m telling the browser it’s getting a PNG image. I am also scaling the image to be 450 by 50 (Code below).&lt;/p&gt;

&lt;p&gt;Once I have a scaled image, I send it back down to the client.&lt;/p&gt;

&lt;h3&gt;Scaling an Image&lt;/h3&gt;

&lt;p&gt;An image might be uploaded that’s 3000x4000 or some other ugly size. No one wants to get sent an image that size on the web for previewing… no one…. So I decide to trim it down.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3fc4e572-1e24-4d94-a4ad-99a59ee8fbc0" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px; white-space: nowrap"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;double&lt;/span&gt; GetScale(&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;[] image, &lt;span style="color:#0000ff"&gt;double&lt;/span&gt; width, &lt;span style="color:#0000ff"&gt;double&lt;/span&gt; height)&lt;br&gt;
{&lt;br&gt;
    &lt;span style="color:#0000ff"&gt;try&lt;/span&gt;&lt;br&gt;
    {&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;double&lt;/span&gt; scale = 1.0;&lt;br&gt;
        System.IO.&lt;span style="color:#2b91af"&gt;MemoryStream&lt;/span&gt; ms = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MemoryStream&lt;/span&gt;(image);&lt;br&gt;
        System.Drawing.&lt;span style="color:#2b91af"&gt;Image&lt;/span&gt; img = System.Drawing.&lt;span style="color:#2b91af"&gt;Image&lt;/span&gt;.FromStream(ms);&lt;br&gt;
&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;double&lt;/span&gt; sX, sY;&lt;br&gt;
        sX = width / img.Width;&lt;br&gt;
        sY = height / img.Height;&lt;br&gt;
&lt;br&gt;
        ms.Close();&lt;br&gt;
        ms.Dispose();&lt;br&gt;
        ms = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;
        img.Dispose();&lt;br&gt;
        img = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
        &lt;span style="color:#008000"&gt;//we have the scale and the 64bit string.&lt;/span&gt;&lt;br&gt;
        scale = &lt;span style="color:#2b91af"&gt;Math&lt;/span&gt;.Min(sX, sY);&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; scale;&lt;br&gt;
    }&lt;br&gt;
    &lt;span style="color:#0000ff"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt; ex)&lt;br&gt;
    {&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;Error geting scale&amp;quot;&lt;/span&gt;, ex);&lt;br&gt;
    }&lt;br&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;I’m passing in the byte[] and the width / height that I want. After I get the scale needed, I scale the image:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:12d41834-228e-4cc5-830e-0177f7dc8c81" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px; white-space: nowrap"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Image&lt;/span&gt; ScaleByPercent(&lt;span style="color:#2b91af"&gt;Image&lt;/span&gt; image, &lt;span style="color:#0000ff"&gt;float&lt;/span&gt; percent)&lt;br&gt;
{&lt;br&gt;
    &lt;span style="color:#0000ff"&gt;try&lt;/span&gt;&lt;br&gt;
    {&lt;br&gt;
        &lt;span style="color:#2b91af"&gt;Bitmap&lt;/span&gt; result = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (image != &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;br&gt;
        {&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
            &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; destWidth = (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)((&lt;span style="color:#0000ff"&gt;float&lt;/span&gt;)image.Width * percent);&lt;br&gt;
            &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; destHeight = (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)((&lt;span style="color:#0000ff"&gt;float&lt;/span&gt;)image.Height * percent);&lt;br&gt;
&lt;br&gt;
            &lt;span style="color:#2b91af"&gt;Rectangle&lt;/span&gt; srcRec = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Rectangle&lt;/span&gt;(0, 0, image.Width, image.Height);&lt;br&gt;
            &lt;span style="color:#2b91af"&gt;Rectangle&lt;/span&gt; destRec = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Rectangle&lt;/span&gt;(0, 0, destWidth, destHeight);&lt;br&gt;
&lt;br&gt;
            result = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Bitmap&lt;/span&gt;(destWidth, destHeight);&lt;br&gt;
            result.SetResolution(image.HorizontalResolution, image.VerticalResolution);&lt;br&gt;
&lt;br&gt;
            &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;Graphics&lt;/span&gt; g = &lt;span style="color:#2b91af"&gt;Graphics&lt;/span&gt;.FromImage(result))&lt;br&gt;
            {&lt;br&gt;
                g.InterpolationMode = System.Drawing.Drawing2D.&lt;span style="color:#2b91af"&gt;InterpolationMode&lt;/span&gt;.HighQualityBicubic;&lt;span style="color:#008000"&gt;//InterpolationMode.HighQualityBicubic;&lt;/span&gt;&lt;br&gt;
                g.DrawImage(image, destRec, srcRec, &lt;span style="color:#2b91af"&gt;GraphicsUnit&lt;/span&gt;.Pixel);&lt;br&gt;
            }&lt;br&gt;
        }&lt;br&gt;
&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; result;&lt;br&gt;
    }&lt;br&gt;
    &lt;span style="color:#0000ff"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt; ex)&lt;br&gt;
    {&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;Error scaling image&amp;quot;&lt;/span&gt;, ex);&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;[] ScaleByPercent(&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;[] image, &lt;span style="color:#0000ff"&gt;float&lt;/span&gt; percent)&lt;br&gt;
{&lt;br&gt;
    &lt;span style="color:#0000ff"&gt;try&lt;/span&gt;&lt;br&gt;
    {&lt;br&gt;
        System.IO.&lt;span style="color:#2b91af"&gt;MemoryStream&lt;/span&gt; ms = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MemoryStream&lt;/span&gt;(image);&lt;br&gt;
        System.Drawing.&lt;span style="color:#2b91af"&gt;Image&lt;/span&gt; img = System.Drawing.&lt;span style="color:#2b91af"&gt;Image&lt;/span&gt;.FromStream(ms);&lt;br&gt;
        &lt;span style="color:#2b91af"&gt;Image&lt;/span&gt; i = ScaleByPercent(img, percent);&lt;br&gt;
&lt;br&gt;
        &lt;span style="color:#2b91af"&gt;MemoryStream&lt;/span&gt; m = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MemoryStream&lt;/span&gt;();&lt;br&gt;
        i.Save(m, System.Drawing.Imaging.&lt;span style="color:#2b91af"&gt;ImageFormat&lt;/span&gt;.Png);&lt;br&gt;
        image = m.ToArray();&lt;br&gt;
&lt;br&gt;
        m.Close();&lt;br&gt;
        ms.Close();&lt;br&gt;
        ms.Dispose();&lt;br&gt;
        m.Dispose();&lt;br&gt;
        m = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;
        ms = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;
        img = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;
        i = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; image;&lt;br&gt;
    }&lt;br&gt;
    &lt;span style="color:#0000ff"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt; ex)&lt;br&gt;
    {&lt;br&gt;
        &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;Error scaling image&amp;quot;&lt;/span&gt;, ex);&lt;br&gt;
    }&lt;br&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And that’s pretty much it.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7614015" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="ASP.NET " scheme="http://weblogs.asp.net/rternier/archive/tags/ASP.NET+/default.aspx" /><category term="AJAX" scheme="http://weblogs.asp.net/rternier/archive/tags/AJAX/default.aspx" /><category term="Image Parsing" scheme="http://weblogs.asp.net/rternier/archive/tags/Image+Parsing/default.aspx" /><category term="ASHX" scheme="http://weblogs.asp.net/rternier/archive/tags/ASHX/default.aspx" /><category term="Image Upload" scheme="http://weblogs.asp.net/rternier/archive/tags/Image+Upload/default.aspx" /></entry><entry><title>JQuery image upload &amp; refresh using an ASHX file.</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2010/08/18/jquery-image-upload-amp-refresh-using-an-ashx-file.aspx" /><id>http://weblogs.asp.net/rternier/archive/2010/08/18/jquery-image-upload-amp-refresh-using-an-ashx-file.aspx</id><published>2010-08-18T19:53:06Z</published><updated>2010-08-18T19:53:06Z</updated><content type="html">&lt;p&gt;I recently finished a solution that uploads an image to my server, and then displays the uploaded image to the user. this is all done “asynchrously”, and it’s within an update panel to boot.&lt;/p&gt;  &lt;p&gt;There are a good handful of solutions for doing this. One of the most popular is &lt;a href="http://demo.swfupload.org/v220/index.htm"&gt;SWFUpload&lt;/a&gt; but I didn’t want to use any flash in my solution – some customers will not have it or it is blocked by some agencies… yes in the real world large agencies and corporations still use IE6 so HTML5… I’ll see you in a few years… back on track.&lt;/p&gt;  &lt;p&gt;For the image upload I used a simple JQuery script written by &lt;a href="http://valums.com"&gt;Andris Valums&lt;/a&gt;. Out of all the scripts I looked at, this was the most straight forward, easy to implement, and had no inner tweaks that could cause issues in the future.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9beece75-491c-4d13-815e-00dc498b49fa" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;function&lt;/span&gt; initSignature(userID) {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    refreshSignature(userID);&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; button = $(&lt;span style="color:#800000"&gt;&amp;#39;#dUpload&amp;#39;&lt;/span&gt;), interval;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; AjaxUpload(&lt;span style="color:#800000"&gt;&amp;quot;#dUpload&amp;quot;&lt;/span&gt;, {&lt;/li&gt; &lt;li&gt;        action: &lt;span style="color:#800000"&gt;&amp;quot;../../handlers/ProcessSignature.ashx&amp;quot;&lt;/span&gt;,&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        name: &lt;span style="color:#800000"&gt;&amp;quot;Signature&amp;quot;&lt;/span&gt;,&lt;/li&gt; &lt;li&gt;        data: { &lt;span style="color:#800000"&gt;&amp;quot;UserID&amp;quot;&lt;/span&gt;: userID, &lt;span style="color:#800000"&gt;&amp;quot;Type&amp;quot;&lt;/span&gt;: &lt;span style="color:#800000"&gt;&amp;quot;Upload&amp;quot;&lt;/span&gt; },&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        obSubmit: &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; (file, ext) {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (ext &amp;amp;&amp;amp; /^(bmp|jpg|png|jpeg|gif)$/.test(ext)) {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#006400"&gt;// change button text, when user selects file.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                button.text(&lt;span style="color:#800000"&gt;&amp;quot;Uploading&amp;quot;&lt;/span&gt;);                            &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.disable();&lt;span style="color:#006400"&gt;//don&amp;#39;t upload any more files.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                interval = window.setInterval(&lt;span style="color:#0000ff"&gt;function&lt;/span&gt; () {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; text = button.text();&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (button.text().length &amp;lt; 13)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                        button.text(button.text() + &lt;span style="color:#800000"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                        button.text(&lt;span style="color:#800000"&gt;&amp;quot;Uploading&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    $(&lt;span style="color:#800000"&gt;&amp;quot;#dMessage&amp;quot;&lt;/span&gt;).text(&lt;span style="color:#800000"&gt;&amp;quot;Uploading &amp;quot;&lt;/span&gt; + file);&lt;/li&gt; &lt;li&gt;                }, 200);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            }&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff"&gt;else&lt;/span&gt; {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#006400"&gt;//Extension is not allowed.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                $(&lt;span style="color:#800000"&gt;&amp;quot;#dMessage&amp;quot;&lt;/span&gt;).text(&lt;span style="color:#800000"&gt;&amp;quot;Error: only images are allowed&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        },&lt;/li&gt; &lt;li&gt;        onComplete: &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; (file, response) {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            button.text(&lt;span style="color:#800000"&gt;&amp;quot;Upload&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#006400"&gt;//although plugins emulates hover effect automatically it doesn&amp;#39;t work when button is disabled&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            button.removeClass(&lt;span style="color:#800000"&gt;&amp;quot;hover&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;            window.clearInterval(interval);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            $(&lt;span style="color:#800000"&gt;&amp;quot;#dMessage&amp;quot;&lt;/span&gt;).text(response);&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (response.indexOf(&lt;span style="color:#800000"&gt;&amp;quot;successful&amp;quot;&lt;/span&gt;) &amp;gt; -1) {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                refreshSignature(userID);&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#006400"&gt;//enable upload button&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.enable();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        }&lt;/li&gt; &lt;li&gt;    });&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Seeing this is inside an update panel I wrapped the initialization script inside a function which I call from the script manager when the UpdatePanel is updated.&lt;/p&gt;  &lt;p&gt;Once the image is uploaded I refresh the image by clearing out the containing div and recreating the image element.&amp;#160; This is a tricky one. Even though the image element was deleted and recreated, the SRC was the same so browsers were caching the image. I decided to throw in an extra random value to the URL so the browser would be forced to get the newest image.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:296379b6-d5e9-45e9-bece-95b307632525" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;function&lt;/span&gt; refreshSignature(userID) {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    $(&lt;span style="color:#800000"&gt;&amp;quot;#signature&amp;quot;&lt;/span&gt;).hide();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; sPath = &lt;span style="color:#800000"&gt;&amp;quot;../../handlers/ProcessSignature.ashx?type=View&amp;amp;UserID=&amp;quot;&lt;/span&gt; + userID + &lt;span style="color:#800000"&gt;&amp;quot;&amp;amp;d=&amp;quot;&lt;/span&gt; + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);&lt;/li&gt; &lt;li&gt;    $(&lt;span style="color:#800000"&gt;&amp;quot;#signature&amp;quot;&lt;/span&gt;).attr({ src: sPath });&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    setTimeout(&lt;span style="color:#0000ff"&gt;function&lt;/span&gt; () { $(&lt;span style="color:#800000"&gt;&amp;quot;#signature&amp;quot;&lt;/span&gt;).imageScale({ maxWidth:450, maxHeight: 50 }) }, 1000);&lt;/li&gt; &lt;li&gt;    $(&lt;span style="color:#800000"&gt;&amp;quot;#signature&amp;quot;&lt;/span&gt;).fadeOut(100).delay(2000).fadeIn(1000);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;At the end I scale the image using a very simple JQuery image scaling plug-in. Below are the JS script files I used.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Image Scaling JS - &lt;a href="http://bicnet.org/files/jquery.custom.js"&gt;http://bicnet.org/files/jquery.custom.js&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;File Upload JS - &lt;a href="http://bicnet.org/files/fileuploader.js"&gt;http://bicnet.org/files/fileuploader.js&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Hope this helps anyone looking to do something similar.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7596115" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="ASP.NET " scheme="http://weblogs.asp.net/rternier/archive/tags/ASP.NET+/default.aspx" /><category term="General Software Development" scheme="http://weblogs.asp.net/rternier/archive/tags/General+Software+Development/default.aspx" /><category term="JQuery" scheme="http://weblogs.asp.net/rternier/archive/tags/JQuery/default.aspx" /></entry><entry><title>Visio 2010 forward engineer add-in for office 2010</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2010/06/17/visio-2010-forward-engineer-add-in-for-office-2010.aspx" /><id>http://weblogs.asp.net/rternier/archive/2010/06/17/visio-2010-forward-engineer-add-in-for-office-2010.aspx</id><published>2010-06-17T17:02:00Z</published><updated>2010-06-17T17:02:00Z</updated><content type="html">&lt;p&gt;I have been scouring the internet for ages trying to see if there was a usable add-on for Visio 2010 that could export SQL Scripts. MS stopping putting that functionality in Visio since 2003 – which is a huge shame.&lt;/p&gt;  &lt;p&gt;Today I found an open source project from &lt;a href="http://sqlblog.com/blogs/alberto_ferrari/default.aspx"&gt;Alberto Ferrari&lt;/a&gt;. It’s an add-in for Visio 2010 that allows you to generate SQL Scripts from your DB diagram. It’s still in beta, and the source is available.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Check it out here:&lt;a href="http://sqlblog.com/blogs/alberto_ferrari/archive/2010/04/16/visio-forward-engineer-addin-for-office-2010.aspx"&gt;http://sqlblog.com/blogs/alberto_ferrari/archive/2010/04/16/visio-forward-engineer-addin-for-office-2010.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This saves me from having to do all my diagramming in SQL Server / VS 2010. And brings back the much needed functionality that has been lost.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7534601" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="SQL" scheme="http://weblogs.asp.net/rternier/archive/tags/SQL/default.aspx" /><category term="Visio" scheme="http://weblogs.asp.net/rternier/archive/tags/Visio/default.aspx" /><category term="Community News" scheme="http://weblogs.asp.net/rternier/archive/tags/Community+News/default.aspx" /></entry><entry><title>Java Script – Content delivery networks (CDN) can bite you in the butt.</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2010/06/14/java-script-content-delivery-networks-cdn-can-bit-you-in-the-butt.aspx" /><id>http://weblogs.asp.net/rternier/archive/2010/06/14/java-script-content-delivery-networks-cdn-can-bit-you-in-the-butt.aspx</id><published>2010-06-14T16:16:00Z</published><updated>2010-06-14T16:16:00Z</updated><content type="html">&lt;p&gt;As much as I love the new CDN’s that Google, Microsoft and a few others have publically released, there are some strong gotchas that could come up and bite you in the ass if you’re not careful. But before we jump into that, for those that are not 100% sure what a CDN is (besides Canadian).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Content Delivery Network.&lt;/h2&gt;  &lt;p&gt;A way of distributing your static content across various servers in different physical locations.&amp;#160; Because this static content is stored on many servers around the world, whenever a user needs to access this content, they are given the closest server to their location for this data. &lt;/p&gt;  &lt;p&gt;Already you can probably see the immediate bonuses to a system like this:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Lower bandwidth&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;Even small script files downloaded thousands of times will start to take a noticeable hit on your bandwidth meter.&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;Less connections/hits to your web server which gives better latency&lt;/li&gt;    &lt;li&gt;If you manage many servers, you don’t need to manually update each server with scripts.&lt;/li&gt;    &lt;li&gt;A user will download a script for each website they visit. If a user is redirected to many domains/sub-domains within your web site, they might download many copies of the same file. When a system sees multiple requests from the same&amp;#160; domain, they will ignore the download&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Those are just a handful of the many bonuses a CDN will give you. And for the average website, a CDN is great choice. Check out the following CDN links for their solutions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Google AJAX Library: &lt;a href="http://code.google.com/apis/ajaxlibs/"&gt;http://code.google.com/apis/ajaxlibs/&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Microsoft Ajax library: &lt;a href="http://www.asp.net/ajaxlibrary/cdn.ashx"&gt;http://www.asp.net/ajaxlibrary/cdn.ashx&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;The Gotcha&lt;/h2&gt;  &lt;p&gt;There is always a catch. Here are some issues I found with using CDN’s that hopefully can help you make your decision.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;HTTP / HTTPS&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;If you are running a website behind SSL, make sure that when you reference your CDN data that you use https:// vs. http://. If you forget this users will get a very nice message telling them that their secure connection is trying to access unsecure data. For a developer this is fairly simple, but general users will get a bit anxious when seeing this.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;Trusted Sites&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;Internet Explorer has this really nifty feature that allows users to specify what sites they trust, and by some defaults IE7 only allows trusted sites to be viewed.&amp;#160; No problem, they set your website as trusted. But what about your CDN? If a user sets your websites to trusted, but not the CDN, they will not download those static files. This has the potential to totally break your web site.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;Pedantic Network Admins&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;This alone is sometimes the killer of projects. However, always be careful when you are going to use a CDN for a professional project. If a network / security admin sees that you’re referencing an outside source, or that a call from a website might hit an outside domain.. panties will be bunched, emails will be spewed out and well, no one wants that.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7530254" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="JavaScript" scheme="http://weblogs.asp.net/rternier/archive/tags/JavaScript/default.aspx" /><category term="General Software Development" scheme="http://weblogs.asp.net/rternier/archive/tags/General+Software+Development/default.aspx" /><category term="CDN" scheme="http://weblogs.asp.net/rternier/archive/tags/CDN/default.aspx" /><category term="JQuery" scheme="http://weblogs.asp.net/rternier/archive/tags/JQuery/default.aspx" /></entry><entry><title>We call them software factories</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2009/12/14/we-call-them-software-factories.aspx" /><id>http://weblogs.asp.net/rternier/archive/2009/12/14/we-call-them-software-factories.aspx</id><published>2009-12-14T19:30:51Z</published><updated>2009-12-14T19:30:51Z</updated><content type="html">&lt;p&gt;When I first started designing and architecting online applications, we decided to move custom settings from a database to an XML file for more versatile settings for our customers. With hundreds of agencies using our system, we needed to have the ability to easily and quickly change settings on a customers website without making core-code changes, XML allowed this. However, a year after we released we found issues with this setup.&amp;#160; &lt;/p&gt;  &lt;p&gt;The setup it self was solid, however we didn’t expect the needs of our customers to be so… unique.&lt;/p&gt;  &lt;h2&gt;&lt;u&gt;Enter the 80/20 rule.&lt;/u&gt;&lt;/h2&gt;  &lt;p&gt;Where once a button click would say print a Circle on a screen, we found soon that 20% of our customers wanted that to be an oval – so we bite the bullet and make a few code changes to accept more settings and voila, a customer can either have an oval or a circle.&lt;/p&gt;  &lt;p&gt;Oh, if it was that easy! Soon, every customer now wanted something different. A Triangle, square, 3D Sphear, dishwasher, and some wanted&amp;#160; a few Ninjas! Come on! Ninjas are rare and priceless, we can’t just give thos…. sorry I digressed.&lt;/p&gt;  &lt;p&gt;What what to do? Do we throw in 100 conditional statements? Do we build a system that is intelligent enough to almost be self aware to know what our customers want? (Any programmer knows that we need to know what our customers need/want/deserve before they actually know they need/want/deserver it).&lt;/p&gt;  &lt;p&gt;So where did we go? The solution was custom libraries for each customer, using reflection at run time to load those libraries up.&lt;/p&gt;  &lt;p&gt;You see, the customer who wants a triangle, didn’t care about the sphear, the circle, the ninja. They wanted triangle, pointy edges and all.&amp;#160; The same went for other customers, so the answer was clear. &lt;/p&gt;  &lt;p&gt;With this implementation, we rarely have to make any core-code changes. Instead, we derive a new library off of a base class, add the functionality needed for our customer, and release it. Plain and simple.&amp;#160; &lt;/p&gt;  &lt;p&gt;A sample of this will be uploaded shortly.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Model&lt;/u&gt;&lt;/strong&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;BicNet.Projects.FactoryExample.Factory&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://weblogs.asp.net/blogs/rternier/image11_4EBB2AA9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rternier/image11_thumb_347AC185.png" width="229" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This project holds the 2 classes I’ll be working with. Each class(factory) has a static method called “Create” which creates the correct Object based on the passed in path.&lt;/p&gt;  &lt;p&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;strong&gt;BicNet.Projects.FactoryExample.Base&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image7_19CE256C.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rternier/image7_thumb_1F3C9610.png" width="193" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There are two&amp;#160; classes in this project: Greeting and Shape.&lt;/p&gt;  &lt;p&gt;These two classes will be the ones overridden by our “factories” to produce custom actions and events.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;strong&gt;BicNet.Projects.FactoryExample.Triangle / Square&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://weblogs.asp.net/blogs/rternier/image22_0FB98441.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rternier/image22_thumb_354301A2.png" width="202" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is derived from BicNet.Projects.FactoryExample.Base.&amp;#160; Greeting and Shape both inherit from Base.Greeting and Base.Shape. This allows me to cast a BicNet.Projects.FactoryExample.Triangle.Shape object as a BicNet.Projects.FactoryExample.Base.Shape, while retaining all the functionality of .Triangle.Shape (Gota love Managed Code).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I’m not going to show BicNet.Projects.FactoryExample.Square because it’s the same as Triangle&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So how does this all work. Let’s look at the FactoryExample.Factory project.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Some Code&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; BicNet.Projects.FactoryExample.Factory&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; FGreeting&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; BicNet.Projects.FactoryExample.Base.Greeting Create(&lt;span class="kwrd"&gt;string&lt;/span&gt; path)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; className = path + &lt;span class="str"&gt;&amp;quot;.Greeting&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="rem"&gt;//Must use System.Reflection.Assembly - can not just use Assembly as the name as &lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            &lt;span class="rem"&gt;//it will not work. Can also use [Assembly] instead&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; (BicNet.Projects.FactoryExample.Base.Greeting)System.Reflection.Assembly.Load(path).CreateInstance(className);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;What’s being passed into the Create(..) method would be: “BicNet.Projects.FactoryExample.Square”.&amp;#160; What this then does is look for that assembly and return the “Greeting” object from that Library. It will then return it, giving me full control over that object.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnLoadFactory_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            BicNet.Projects.FactoryExample.Base.Shape shape = BicNet.Projects.FactoryExample.Factory.FShape.Create(ddlFactories.SelectedItem.Text);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            BicNet.Projects.FactoryExample.Base.Greeting greeting = BicNet.Projects.FactoryExample.Factory.FGreeting.Create(ddlFactories.SelectedItem.Text);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            lblGetShapeName.Text = shape.GetShapeName();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            lblGetShape.Text = shape.GetCustomText();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            lblGetGreeting.Text = greeting.GetGreeting();    &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        }&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;What’s the Point?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, this is very simple with shapes and such, however what about real world scenarios? One of the main questions I’ve been asked about with this model is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;If you just did market research and you knew what your customers wanted, you wouldn’t need to make a system like this. Why spend the extra time and effort to build a system that’s capable of doing this when you could just do what customers wanted in the first place?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Anyone in the Software industry can tell you customers don’t always know what they want, and customer’s needs change every day / week / year (hour?). And, for those that deal with $$, maintenance on any application is usually the big killer for time (effort) and money.&lt;/p&gt;

&lt;p&gt;Another argument might be:&lt;/p&gt;

&lt;p&gt;You have 500 customers working on an Item Tracking&amp;#160; System (Tasks, to-do’s etc.).&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;300 of those customers want it when they submit an item, for an email to be sent to themselves, and to the people assigned to the task. &lt;/li&gt;

  &lt;li&gt;100 of those customers want 2 sub-tasks created for each Task created, and both those tasks to be automatically assigned to “Mary Smith” in the system. &lt;/li&gt;

  &lt;li&gt;50 of the 100 remaining customers want a PDF created as soon as the Task is created to be saved as a snapshot of the original task. &lt;/li&gt;

  &lt;li&gt;25 of the 100 want any task that is completed to have a PDF snapshot taken, saved in a specific directory so their FTP program can look for them. &lt;/li&gt;

  &lt;li&gt;The final 25 customers don’t know what they want, but we are safe because as soon as they come up with whatever customers come up with, we have the ability to plug it in without changing base code because we can just change their factory. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;That’s it?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well pretty much. Yes, you could get the above done with XML – if you knew what you were facing before you started. However, that’s not the problem we face in our industry. We are always changing and always improving. Having the ability to quickly change something for a customer or set of customers without interupting the flow of everything else, is what we want. Maintenance is always the big cost item with Web Applications because of the ongoing changes to it.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7278715" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="ASP.NET " scheme="http://weblogs.asp.net/rternier/archive/tags/ASP.NET+/default.aspx" /><category term="Ninjas" scheme="http://weblogs.asp.net/rternier/archive/tags/Ninjas/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/rternier/archive/tags/C_2300_/default.aspx" /><category term="Reflection" scheme="http://weblogs.asp.net/rternier/archive/tags/Reflection/default.aspx" /></entry><entry><title>Microsoft Expressions – Web Super Preview</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2009/04/02/microsoft-expressions-web-super-preview.aspx" /><id>http://weblogs.asp.net/rternier/archive/2009/04/02/microsoft-expressions-web-super-preview.aspx</id><published>2009-04-02T18:21:06Z</published><updated>2009-04-02T18:21:06Z</updated><content type="html">&lt;p&gt;So Here I am trying to figure out how to test my application in IE6, IE7, IE8 and the rest of the plethora of browsers. Aside from the fact that my customers still use IE6… … I couldn’t find a computer / RDP / VM Machine that has IE6 on it.&amp;#160; Through my searching, I found this beauty:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.webdesignerdepot.com/2009/03/microsoft-announces-superpreview-for-ie-browser-testing/" href="http://www.webdesignerdepot.com/2009/03/microsoft-announces-superpreview-for-ie-browser-testing/"&gt;http://www.webdesignerdepot.com/2009/03/microsoft-announces-superpreview-for-ie-browser-testing/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This gives the ability to have multiple versions of IE looking at the same web page. Now, it’s not perfect but it’s a start (it’s still in beta). you can see by the picture below that the textbox I’ve selected on the left side (IE8), selects the same textbox on the right side, however the position is off.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_3BB98EB4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_738BD2D7.png" width="877" height="73" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;My thoughts:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;It’s good if you’re looking at a plain page, however there is no user interaction. You can’t navigate, you can’t type, you can’t do much except watch and look at positioning.&lt;/li&gt;    &lt;li&gt;It does help with CSS issues… like putting : style=”display:none;” on a textbox. It works in IE7+ but not in IE6.&lt;/li&gt;    &lt;li&gt;The download for the install is 236MB, yet the program you’re installing is only 36megs after install… what else is in there?&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So if you’re looking for a page by page comparison, don’t need to test ajax, or anything else, this works.&amp;#160; Personally, I’m getting someone to build me a Win98 VM and a Windows XP VM so I can have those running to test my apps.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7023176" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author></entry><entry><title>Hosts file auto updated to IP v6…</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2009/03/09/hosts-file-auto-updated-to-ip-v6.aspx" /><id>http://weblogs.asp.net/rternier/archive/2009/03/09/hosts-file-auto-updated-to-ip-v6.aspx</id><published>2009-03-09T23:10:00Z</published><updated>2009-03-09T23:10:00Z</updated><content type="html">&lt;p&gt;We had an issue today at work. A few developer machines couldn’t debug any ASP.NET 2.0 web application. After an hour of looking, we found out that some of our host files had the entry:&lt;/p&gt;  &lt;p&gt;::0&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; localhost&lt;/p&gt;  &lt;p&gt;instead of:&lt;/p&gt;  &lt;p&gt;127.0.0.1&amp;#160;&amp;#160;&amp;#160;&amp;#160; localhost&lt;/p&gt;  &lt;p&gt;If you are getting issues with trying to debug your ASP.NET Website (Like the following):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_43A094E4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_5D945506.png" width="567" height="262" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_5BE38932.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_43243C22.png" width="834" height="572" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Check your hosts file to make sure it’s correct.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6951934" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author></entry><entry><title>Application logging – yes it is important</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2009/02/19/application-logging-yes-it-is-important.aspx" /><id>http://weblogs.asp.net/rternier/archive/2009/02/19/application-logging-yes-it-is-important.aspx</id><published>2009-02-19T22:42:00Z</published><updated>2009-02-19T22:42:00Z</updated><content type="html">&lt;p&gt;I’ve spent most of my professional career working on Enterprise Applications (mostly web based). Sometimes you release your code and everything goes smoothly (this is where praise is warranted by rarely given). However, there are times when code has been in place for many days, weeks, months without any issues and all of a sudden – all hell breaks loose and it stops (this is where harsh comments are never wanted but always received).&lt;/p&gt;  &lt;p&gt;So, what do we do when that happens? If we cannot see what’s going on, we’re pretty much hosed. Sure we could start doing some knee-jerk reactions, do code changes to try trapping for situations, but come on… knee-jerk reactions are bad. Say it with me: “BAD”.&lt;/p&gt;  &lt;p&gt;So this is where application logging comes in.&amp;#160; Below are 2 lists. The first list contains some things you just should not do… though everyone has probably done these. We learn through making mistakes, others and school (… yea), so the list below is mostly mistakes I’ve made in my career so hopefully some can learn from them. &lt;/p&gt;  &lt;h4&gt;What Not To do.&lt;/h4&gt;  &lt;p&gt;There are many ways to “log” what happens in an application. What I want to do here is list some of the ones I’ve encountered that really don’t give much info.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Rely on just Exception Logs&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;There is something to be said about logging exceptions, however, relying on just exception logs is a mistake. Exceptions are raised either when a code error, system exception, user exception or when a user manually throws it. However there are cases where there’s an error with your system, and it’s not throwing an exception. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Write out every action to the Hard Disk&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I love this one. I’ve seen a system log over 100Mb an HOUR to the hard disk based on actions happening on it. Sure, it could be useful… if you had a hard disk that had a crap load of room on it. But come on, you let it run for a month un-checked. 100 * 24… um * 30… dot the i…&amp;#160; … that’s around 72GB of logging. Yes, some of it “might” be useful but who would want the daunting task of looking through that mess when we could doing real work.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Use a single log file&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Whenever you log information to the system – split it up into files. One file per day, or one file per hour. If you have a log file that’s massive (look above) and you’re reading it every time you log something, you’ll be overloading your system in no time on read/writes. What i do is:&amp;#160;&amp;#160;&amp;#160; name files like:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;BicNet.Enfora_LOG_19_FEB_2008_0800.log&lt;/li&gt;    &lt;li&gt;BicNet.Enfora_LOG_19_FEB_2008_0900.log&lt;/li&gt;    &lt;li&gt;BicNet.BlueTree_LOG_19_FEB_2008_0800.log&lt;/li&gt;    &lt;li&gt;BicNet.AI.NinjaRevengePlan2000_LOG_59_SEPTEBURARY_2108_0800.log&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If an error occurs at 8:30AM with some customers sending in GPS Data through an Enfora Modem, it’s pretty self-explanatory where I need to look.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Do nothing&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;YES! Awesome!… die… well actually this is better than the next one.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Log useless information&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Have you ever seen a log file that looks like:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt;Awesome function just called. Woo I rock. Go Canucks go! &lt;/p&gt;    &lt;p&gt;&amp;gt;Another Awesome function was just called. It’s now 12:34PM. GO CANADA GO! &lt;/p&gt;    &lt;p&gt;&amp;gt;WOO I ROCK! &lt;/p&gt;    &lt;p&gt;&amp;gt;… Stupid user did an error. Message is “Object reference not set to an instance of an object”. COME ON! &lt;/p&gt;    &lt;p&gt;&amp;gt;ANOTHER ERROR!? Gah button1 was clicked. Check the code to see why I was written. DO IT! DO IT NOW!&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;If you looked through some of my college programs you might find some error logs like this. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;What to do&lt;/h1&gt;  &lt;p&gt;Honestly, don’t do any of the above and you’re better off already. There’s an example of a logging system I have in place that writes logs out.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Don’t bloat your logs&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When doing logs – I rarely use XML. Wha!? NO XML!? HERESY! Yes yes it formats nicely, and yes it’s well it’s XML. However, there’s an overhead on using it. Only use it if you need to. If you can get by with writing logs in plain text, do it. XML can be used when you have complex object you need to write out, or if you nave a lot of data, however, for simple logging – use plain text.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Log raw information coming into the system&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Whenever you have a system that needs it’s information logged, log the incoming data. If you don’t log that data, it could be transformed or corrupted at the time you do log it. If you log it when it’s coming in you can later on run tests against that function with the correct data if there’s an error. For web services, there’s ways of tapping into the raw SOAP data (using ASP.NET) before it hits your web-service. This allows you to log/trace that information to your disk before your web-service gets the data, very useful.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Example – UDP / TCP Listener&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I have a service running on our servers that listens on TCP and UDP Ports. Whenever a device connects to our servers, my listener service picks it up and processes the information.&amp;#160; Every time I get a connection on our server, I log who connected, the message received, and the time (I don’t write anything out at this time). Every time I send something to a user, I log the IP, the message and the time. Every 10 minutes I’ll stream the output to one file, and the input to another file. If an exception is raised, I write out all the information, as well as the exception to an exception log file. Every hour I create a new file so they’re never too large.&lt;/p&gt;  &lt;p&gt;I don’t log every function, I don’t log simple operations, I don’t need to because if they ever throw an exception, I already have it. If there is bad data coming in which is compromising the integrity of my system, I have it already logged with the date/time. This gives us all the information we need to perform tests to see what has gone wrong, and it catches exceptions. It also allows me to quickly count the # of connections coming in, to debug connectivity issues.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Code Example – Generic Log Entry Method&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Here’s a sample “Logging” method I use to fill my StringBuilder with the data I need to log out:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LogEntry(&lt;span class="kwrd"&gt;string&lt;/span&gt; message, &lt;span class="kwrd"&gt;string&lt;/span&gt; customer, &lt;span class="kwrd"&gt;int&lt;/span&gt; reportID)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; sReportID = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            &lt;span class="kwrd"&gt;char&lt;/span&gt; c = &lt;span class="str"&gt;' '&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            System.Diagnostics.Debug.WriteLine(message);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (_sbLog == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                _sbLog = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (reportID &amp;gt; -1)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                sReportID = reportID.ToString();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (customer != &lt;span class="kwrd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; customer.Length &amp;gt; 25)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                customer = customer.Substring(0, 25);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (sReportID != &lt;span class="kwrd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; sReportID.Length &amp;gt; 9)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;                sReportID = &lt;span class="str"&gt;&amp;quot;XX&amp;quot;&lt;/span&gt; + sReportID.Substring(2, 7);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (message.ToLower().IndexOf(&lt;span class="str"&gt;&amp;quot;exception&amp;quot;&lt;/span&gt;) &amp;gt; -1)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;                _sbLog.AppendLine(&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;                    DateTime.Now&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;                    + &lt;span class="str"&gt;&amp;quot; - &amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;                    + (customer == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 25) : customer + &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 25 - customer.Length))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;                    + &lt;span class="str"&gt;&amp;quot; - &amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;                    + (sReportID == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 9) : sReportID + &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 9 - sReportID.Length))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;                    + &lt;span class="str"&gt;&amp;quot; - &amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;                    + &lt;span class="str"&gt;&amp;quot;Exception occured.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;                _sbLog.AppendLine(message);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;                _sbLog.AppendLine(&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;                    DateTime.Now&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;                    + &lt;span class="str"&gt;&amp;quot; - &amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;                    + (customer == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 25) : customer + &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 25 - customer.Length))&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;                    + &lt;span class="str"&gt;&amp;quot; - &amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;                    + (sReportID == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 9) : sReportID + &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(c, 9 - sReportID.Length))&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;                    + &lt;span class="str"&gt;&amp;quot; - &amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;                    + message);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;From here, you just have to tell it to write this out whenever you need.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6917250" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="ASP.NET " scheme="http://weblogs.asp.net/rternier/archive/tags/ASP.NET+/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/rternier/archive/tags/C_2300_/default.aspx" /><category term="General Software Development" scheme="http://weblogs.asp.net/rternier/archive/tags/General+Software+Development/default.aspx" /></entry><entry><title>Hiring more developers doesn’t always speed things up.</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2009/02/19/hiring-more-developers-doesn-t-always-speed-things-up.aspx" /><id>http://weblogs.asp.net/rternier/archive/2009/02/19/hiring-more-developers-doesn-t-always-speed-things-up.aspx</id><published>2009-02-19T17:05:30Z</published><updated>2009-02-19T17:05:30Z</updated><content type="html">&lt;p&gt;Who’s heard of the term : “Too many cooks in the kitchen”? It’s a fundamental problem if ruling.&lt;/p&gt;  &lt;p&gt;I was talking to someone awhile ago about this problem where they needed to get Task A done in a specific time frame and his boss wanted him to just hire more developers.&lt;/p&gt;  &lt;p&gt;So I’ll give the same answer to you that we talked about:&lt;/p&gt;  &lt;p&gt;It takes 9 months for a baby to be born. If you add 9 women into the fray, would the baby be born in 1 month?&lt;/p&gt;  &lt;p&gt;I’ll stop there so minds don’t wander… yea that means you!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6916976" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="General Software Development" scheme="http://weblogs.asp.net/rternier/archive/tags/General+Software+Development/default.aspx" /><category term="Utter Nonsense" scheme="http://weblogs.asp.net/rternier/archive/tags/Utter+Nonsense/default.aspx" /></entry><entry><title>Find All Databases with…?</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2009/02/18/find-all-databases-with.aspx" /><id>http://weblogs.asp.net/rternier/archive/2009/02/18/find-all-databases-with.aspx</id><published>2009-02-18T16:07:44Z</published><updated>2009-02-18T16:07:44Z</updated><content type="html">&lt;p&gt;I work with a lot of databases. Currently, we have over 500 databases on our one SQL box. Whenever I have to go in and modify a a specific XML section, I need a quick way to find any DataBase that has that specific XML text. I came up with a quick Script that goes through every database, searches for the table I want to see if it contains my XML text.&lt;/p&gt;  &lt;p&gt;Here’s a script that has done well for me:    &lt;br /&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Exec&lt;/span&gt; sp_MSforeachdb @command1= &lt;span class="str"&gt;'USE ? IF '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'master'&lt;/span&gt;&lt;span class="str"&gt;' AND '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'model'&lt;/span&gt;&lt;span class="str"&gt;' AND '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'msdb'&lt;/span&gt;&lt;span class="str"&gt;' AND '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'tempdb'&lt;/span&gt;&lt;span class="str"&gt;' 
begin 
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('&lt;/span&gt;&lt;span class="str"&gt;'[dbo].[tblProcessConfigurations]'&lt;/span&gt;&lt;span class="str"&gt;') AND type in ('&lt;/span&gt;&lt;span class="str"&gt;'U'&lt;/span&gt;&lt;span class="str"&gt;')) 
BEGIN 
SELECT * FROM dbo.tblProcessConfigurations 
END 
end'&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;What this will do is print out the contents of every tblProcessConfigurations of every database on my server. However, I had an issue – what Databases were they from?&lt;/p&gt;

&lt;p&gt;I add the simple function: db_name() to my query and voila:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;Exec&lt;/span&gt; sp_MSforeachdb @command1= &lt;span class="str"&gt;'USE ? IF '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'master'&lt;/span&gt;&lt;span class="str"&gt;' AND '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'model'&lt;/span&gt;&lt;span class="str"&gt;' AND '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'msdb'&lt;/span&gt;&lt;span class="str"&gt;' AND '&lt;/span&gt;&lt;span class="str"&gt;'?'&lt;/span&gt;&lt;span class="str"&gt;' &amp;lt;&amp;gt; '&lt;/span&gt;&lt;span class="str"&gt;'tempdb'&lt;/span&gt;&lt;span class="str"&gt;' &lt;/pre&gt;

  &lt;pre&gt;begin &lt;/pre&gt;

  &lt;pre class="alt"&gt;IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('&lt;/span&gt;&lt;span class="str"&gt;'[dbo].[tblProcessConfigurations]'&lt;/span&gt;&lt;span class="str"&gt;') AND type in ('&lt;/span&gt;&lt;span class="str"&gt;'U'&lt;/span&gt;&lt;span class="str"&gt;')) &lt;/pre&gt;

  &lt;pre&gt;BEGIN &lt;/pre&gt;

  &lt;pre class="alt"&gt;print db_name() &lt;/pre&gt;

  &lt;pre&gt;SELECT * FROM dbo.tblProcessConfigurations &lt;/pre&gt;

  &lt;pre class="alt"&gt;END &lt;/pre&gt;

  &lt;pre&gt;end'&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;I can now document every DataBase that will need to be updated, and what the Updates need to be.&amp;#160; &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6915258" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="XML" scheme="http://weblogs.asp.net/rternier/archive/tags/XML/default.aspx" /><category term="SQL" scheme="http://weblogs.asp.net/rternier/archive/tags/SQL/default.aspx" /></entry><entry><title>Google Chrome - A player?</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2008/12/03/google-chrome-a-player.aspx" /><id>http://weblogs.asp.net/rternier/archive/2008/12/03/google-chrome-a-player.aspx</id><published>2008-12-03T22:39:44Z</published><updated>2008-12-03T22:39:44Z</updated><content type="html">&lt;p&gt;So today I'm playing with Google Chrome at work.&amp;#160; From my first look at it, it has promise. There's some beautiful things about it like when one tab freezes for one reason or another (something that would likely shut down Firefox / IE), only that tab freezes and not the entire application - allowing you to continue to work rather than stare at an un-responsive browser.&lt;/p&gt;  &lt;p&gt;The one major beef I have is when fully maximized, there is a 10 pixel gap at the bottom of the screen where you can click on windows behind Chrome – this does annoy me because I have a habit of clicking there – and now that I know it’s there… it will annoy me… …&lt;/p&gt;  &lt;p&gt;There are some cool features thought:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Ability to resize any textarea control &lt;/li&gt;    &lt;li&gt;Screen realastate is huge!&lt;/li&gt;    &lt;li&gt;Google keeps a record of previous and most visited sites. So when you open chrome, you can see them all right there.&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_02DFCEE2.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="146" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_2DA80D27.png" width="244" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;The: Right Click –&amp;gt;Page Info is quite amusing&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_261C9DBA.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="188" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_0C48678B.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;But what do you expect from a Beta… oh wait… isn’t everything from Google in Beta?&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;h1&gt;JavaScript &lt;/h1&gt;  &lt;p&gt;First off I try it against my Vehicle Tracking application I wrote for police agencies in the states. Heck, it's quick. It does everything great! I then started to play with overlaying ESRI data on top of my maps, and working with my playback and history functions and again it amazed me with how quick it is.&amp;#160; The only hiccups I got was when I played around with running 50 simultaneous functions at the same time, each one doing a lot of trig. math. The browser finally gave up and crashed.&amp;#160; I'm not surprised, IE and Firefox did the same.&lt;/p&gt;  &lt;p&gt; So as far as I'm concerned - it works great.&lt;/p&gt;  &lt;h1&gt;&lt;strong&gt; CSS&lt;/strong&gt; &lt;/h1&gt;  &lt;p&gt; There is a bit of issues with CSS styling - mainly I believe it's being too pedantic.&amp;#160; Chrome has a feature that highlights &amp;lt;input /&amp;gt; elements with an orange glow. I can see how this is nice, however to those of us that sometimes spend too much time making our application visual appealing, it’s annoying.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;INcogNITO!&lt;/h1&gt;  &lt;p&gt;IE8 has one, why not Chrome! HIDE EVERYTHING! No Cookies (sorry cookie monster), no traces… can we turn this off? I am personally not putting this browser on my computer at home because I do like to see what goes on with the history – and I don’t want to give anyone using my computer (&amp;lt;cough&amp;gt; kids) the ability to view bad (&amp;lt;wheeze&amp;gt; Sites with Barny the Dinosaur on them) sites without me knowing… stupid dinosaur…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_4486DEA3.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="160" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_18A664E7.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h1&gt;Developer Tools&lt;/h1&gt;  &lt;p&gt;Google Chrome comes with a few developer tools built in.&amp;#160;&amp;#160; The JavaScript debugger failed to impress me. I've used Firebug for the past few years and It's the only one that I will recommend. The JavaScript consol caused Chrome to freeze on me fully. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_1BE7B0F5.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="192" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_4AE9ECCC.png" width="244" border="0" /&gt;&lt;/a&gt; JavaScript Consol&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_2A62AD1A.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="151" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_50C49065.png" width="244" border="0" /&gt;&lt;/a&gt; Javascript Debugger (Command line? What is this COBOL?)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Having the Document Source open in a tab is... ok... and I can see the uses however I do like to move source around while I look at WebPages - why else would you use multiple monitors!?&lt;/p&gt;  &lt;p&gt; The task manager is quite... &amp;quot;nifty&amp;quot;, easy way of telling what applications are running under chrome. I especially appreciate the &amp;quot;Stats for Nerds&amp;quot; option which loads up the memory usage of the browsers (Firefox, IE, Chrome) opened and the processes (tabs) used.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_303D50B3.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="158" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_0896D489.png" width="244" border="0" /&gt;&lt;/a&gt; Task manager&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rternier/image_43EA3A47.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="148" alt="image" src="http://weblogs.asp.net/blogs/rternier/image_thumb_206D95E2.png" width="244" border="0" /&gt;&lt;/a&gt; Memory Usage&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;All in All, it’s better than the beta of IE8 (Sorry MS), but I don’t think It’s going to be the next best thing to hit the Internet. Ninjas did that a long time ago.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6764732" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="Ninjas" scheme="http://weblogs.asp.net/rternier/archive/tags/Ninjas/default.aspx" /><category term="JavaScript" scheme="http://weblogs.asp.net/rternier/archive/tags/JavaScript/default.aspx" /><category term="CSS" scheme="http://weblogs.asp.net/rternier/archive/tags/CSS/default.aspx" /><category term="Google" scheme="http://weblogs.asp.net/rternier/archive/tags/Google/default.aspx" /></entry><entry><title>The grass is greener where you water it.</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2008/03/28/the-grass-is-greener-where-you-water-it.aspx" /><id>http://weblogs.asp.net/rternier/archive/2008/03/28/the-grass-is-greener-where-you-water-it.aspx</id><published>2008-03-29T02:15:00Z</published><updated>2008-03-29T02:15:00Z</updated><content type="html">&lt;p&gt;I love watching people. I like to sit back, and watch peoples expressions, their body movements, their reactions to certain things. I don't really consider it eavesdropping, as I am not paying attention to the conversation, and I don't usually hear what's going on.&amp;nbsp; The other day I was watching a few developers from a larger company here in town bicker about something.. A friend of mine joined their group and saw I was drinking some coffee and invited me over.&amp;nbsp; The conversation soon turned towards working conditions, job satisfaction, salary, management etc... really whatever a group of developers talk about at a coffee shop. Now many would think we'd talk about games, however as "Geeks" we must maintain the persona that we have lives (note Geeks, not nerds... Geeks).&lt;/p&gt;&lt;p&gt;One person then mentioned the well coined phrase "Well the grass is always greener on the other side of the fence". At that point I had to but in and tell him to give his head a shake. The grass is greener where you water it! &lt;/p&gt;&lt;p&gt;As a working individual it is your duty, heck it's your God given duty to put 100% into your career / job. It doesn't matter if it's full time, part time, a "stepping stone", or whatever. If you are getting paid for a job, put your all into it because that's really what you're getting paid for. If you think the grass is greener on the other side, look at where you're at. Think of what makes the grass greener on the other side and bring it up with your manager / boss. Now there are some cases where the grass you're currently on was laid on a bed of concrete, in those rare occasions even the dirt looks greener (And you might want to either talk to your manager about buying an excavator if you're in this boat).&lt;br&gt;&lt;/p&gt;&lt;p&gt;Yes this is a bit of a rant, and it might be because I'm a new dad and my career is very important to my family. But wherever you are in your career, make it the best it can be. Put your all into it. Yes, the company across the street might have the newest computers, or the company across the way has lunch time gaming time... whatever it is, if you put your all into where you are, whenever you decide to move on you'll do it with integrity.&lt;/p&gt;&lt;p&gt;&amp;nbsp;I'm going to change my babies poopy diaper now.&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6043783" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author></entry><entry><title>Acid 3 Test?</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2008/03/16/acid-3-test.aspx" /><id>http://weblogs.asp.net/rternier/archive/2008/03/16/acid-3-test.aspx</id><published>2008-03-17T04:22:00Z</published><updated>2008-03-17T04:22:00Z</updated><content type="html">&lt;p&gt;Yes the &lt;a href="http://acid3.acidtests.org/" mce_href="http://acid3.acidtests.org/"&gt;Acid 3 &lt;/a&gt;test has been released. The &lt;a href="http://www.webstandards.org/press/releases/20080303/" mce_href="http://www.webstandards.org/press/releases/20080303/"&gt;official announcement is here&lt;/a&gt;, and because I loath copy/paste blog posts you will need to go there to read all the nitty/gritty about it. Pretty much Acid3 tests specifications for "web 2.0" (What the heck is web 2.0 anyways? When did the web get an update... I'm still waiting for my CD!). Too see exactly what's tested, check &lt;a href="http://www.webstandards.org/action/acid3/" mce_href="http://www.webstandards.org/action/acid3/"&gt;this &lt;/a&gt;out.&lt;/p&gt;&lt;p&gt;The cool this about this is that It shows the "Percent" on how good your browser is. Believe it or not, IE7 gets like 13%. FireFox 2.0 gets around 52%.&lt;/p&gt;&lt;p&gt;&amp;nbsp;I'm not even going to attempt to do this in IE8 beta.&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5981082" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="XHTML" scheme="http://weblogs.asp.net/rternier/archive/tags/XHTML/default.aspx" /><category term="CSS" scheme="http://weblogs.asp.net/rternier/archive/tags/CSS/default.aspx" /><category term="HTML" scheme="http://weblogs.asp.net/rternier/archive/tags/HTML/default.aspx" /><category term="Acid Test" scheme="http://weblogs.asp.net/rternier/archive/tags/Acid+Test/default.aspx" /></entry><entry><title>IE8 is comming out, FireFox 3 is comming out, When's my duplicate comming out?</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2008/03/16/ie8-is-comming-out-firefox-3-is-comming-out-when-s-my-duplicate-comming-out.aspx" /><id>http://weblogs.asp.net/rternier/archive/2008/03/16/ie8-is-comming-out-firefox-3-is-comming-out-when-s-my-duplicate-comming-out.aspx</id><published>2008-03-17T04:20:00Z</published><updated>2008-03-17T04:20:00Z</updated><content type="html">&lt;p&gt;Holy Cow! I know this isn't new news.&amp;nbsp; IE8 and FireFox 3.. Acid 2 tests, heck &lt;a href="http://weblogs.asp.net/rternier/archive/2008/03/16/acid-3-test.aspx" mce_href="http://weblogs.asp.net/rternier/archive/2008/03/16/acid-3-test.aspx"&gt;Acid 3&lt;/a&gt; tests. When is it going to stop?!?&lt;/p&gt;&lt;p&gt;&amp;nbsp;As some know, I'm writing a very complicated vehicle tracking system that is all web based. It can track up to 200 vehicles at once (in one browser instance), draw them on the map, and give you all the nice tid-bits of information about them. This application is very heavy CSS and JavaScript. I pretty much took most of .NET out of the application except for 3 web service calls.&lt;/p&gt;&lt;p&gt;&amp;nbsp;However, To make applications like the one I'm developing work in a real world environment, they need to be efficient. That means that if I'm going to be doing collision detection on vehicle labels (so they don't overlap) I would rather use a few extra bits of memory to remember the answers from complicated math (storing the values that are returned by using COS / SIN calculations) than to have to calculate them each time. If you didn't know anything done using COS, SIN, TAN etc.&amp;nbsp; are extremely expensive. &lt;/p&gt;&lt;p&gt;&amp;nbsp;So back on topic, I have my application, It's as efficient as I can make it, and now I have to test the efficiency in not 4, but SIX browsers. And to top it off, those browsers have tweaked Javascript engines. WHY WHY WHY! I already tried my app in these 2 new browsers, and they "do" work, but not as well as I would've hoped.&amp;nbsp; Come on, when can a Guy run a simple &amp;lt;div&amp;gt; collision detection script that checks over 100 divs and repositions them in a self expanding circle every second? Why does it need to take 3.2 seconds?&lt;br&gt;&amp;nbsp;&lt;br&gt;I know... to better humanity and all other species on this earth, new web browsers are pertinent in order to form an electronic self sustaining ecosystem. Anyways, WHY! I already have 4 browsers to test (IE7, FireFox 2.0, Opera, safari... stupid Safari), and now I need to test on 2 more? You know, the day when those 2 browsers (or days) get released I'll forget to test on them and I'll get over 100 emails in my inbox stating that my website broke the internet (if that were true then I'd really have something to blog about).&lt;/p&gt;&lt;p&gt;Can we invest more money in holograms like on Star Trek so I can get a duplicate to do the testing? I know testing is the bestest most funnestest thing ever and that programmers everywhere are running at the opportunity to test... but I'll sacrifice my ego and let my hologram clone do it for me.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br&gt;Ok I'll stop whining now.&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5981158" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="JavaScript" scheme="http://weblogs.asp.net/rternier/archive/tags/JavaScript/default.aspx" /><category term="IE8" scheme="http://weblogs.asp.net/rternier/archive/tags/IE8/default.aspx" /><category term="IE7" scheme="http://weblogs.asp.net/rternier/archive/tags/IE7/default.aspx" /><category term="Whining" scheme="http://weblogs.asp.net/rternier/archive/tags/Whining/default.aspx" /><category term="FIreFox 3.0" scheme="http://weblogs.asp.net/rternier/archive/tags/FIreFox+3.0/default.aspx" /></entry><entry><title>Why I love Javascript, and Ie7 hates extra ,'s in prototyping</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/rternier/archive/2008/01/31/why-i-love-javascript-and-ie7-hates-extra-s-in-prototyping.aspx" /><id>http://weblogs.asp.net/rternier/archive/2008/01/31/why-i-love-javascript-and-ie7-hates-extra-s-in-prototyping.aspx</id><published>2008-01-31T18:04:00Z</published><updated>2008-01-31T18:04:00Z</updated><content type="html">&lt;p&gt;I've been working with javascript rather heavily for the past few... many months. Years ago when I started working with ASP.NET I was naive and thought everything should be done server side. I thought that the server should do all the work so the clients computers would be able to work fast.&amp;nbsp; It took only 1 year for me to turn that thinking around.&amp;nbsp; JavaScript rocks!&amp;nbsp; &lt;/p&gt;  &lt;p&gt;ASP.NET AJAX works great with JavaScript.&amp;nbsp; You can point to a web service (in your current domain), get the data you need,&amp;nbsp; and do all the XHTML/HTML Markup changes necessary without a postback to the server. (yes some postbacks are evil)&lt;/p&gt;  &lt;p&gt;So why do I love JavaScript? Aside from the Asynchronous nature of it (which can really screw with your mine sometimes), it makes the client computers do the work, and takes the load of your servers. It might be easy for your server to render a DataList of 100 rows. However, if you need that list updated every 10 seconds with the newest data, your server will start complaining when 1000-10,000 people are viewing that page.&amp;nbsp; You could cache the data, but you'll still be rendering the DataList in your presentation layer.&amp;nbsp; With JavaScript, you can create a simple object (note JavaScript is not an object based language, you use prototypes... but for the simple eye they look like objects) that can do this for you:&lt;/p&gt;  &lt;p&gt;DataItem = function(data)   &lt;br&gt;{    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.UserID = data.UserID;    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.UserName = data.UserName;    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.FullName = data.FullName;    &lt;br&gt;} &lt;/p&gt;  &lt;p&gt;DataItem.prototype = {   &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; toString = function()    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return '&amp;lt;div class="detail"&amp;gt;UserID: ' + this.UserID = ', UserName: ' + this.UserName = ', FullName: ' + this.FullName = '&amp;lt;/div&amp;gt;';    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; },    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; test = function()    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var d = "test";    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return d;    &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; },    &lt;br&gt;}&lt;/p&gt;  &lt;p&gt;When you get the results back from your webservice, you can loop through them, creating this object (yea yea) from the data returned, and easily output the data you need.&amp;nbsp; Very simple, and you have full control. You don't need to rebuild your application if you want to change how a simple list works. &lt;/p&gt;  &lt;p&gt;This is where I left off last night with some script I was working on. I get to the office and I began testing it again, pulling my hair out.&amp;nbsp; FireFox was working fine, however IE7 was blowing up. I kept getting "&amp;lt;custom object&amp;gt; is Undefined".&amp;nbsp; After creating a few test prototypes I found the culprit... the trailing "&lt;b&gt;,&lt;/b&gt;" in the last function of my prototype. IE is expecting there to be a new function, FireFox ignores it.&lt;/p&gt;  &lt;p&gt;JavaScript is strict, and I love it!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5682776" width="1" height="1"&gt;</content><author><name>rternier</name><uri>http://weblogs.asp.net/members/rternier.aspx</uri></author><category term="JavaScript" scheme="http://weblogs.asp.net/rternier/archive/tags/JavaScript/default.aspx" /><category term="IE7" scheme="http://weblogs.asp.net/rternier/archive/tags/IE7/default.aspx" /></entry></feed>