Palermo4 on MSDN

Technical Blog of J. Michael Palermo IV

Check it out!

  • Palermo4 on MSDN

    MIX11 Open Call for Content


    Be a “Best of Web” Presenter at MIX11

    Are you an expert on web development, design or monetization? Do you have interesting and unique information to deliver on creating next generation web sites? Submit your session proposal by Friday, January 14, 2011. The MIX content team will select the best proposals, and the MIX community will vote to determine who will present. Presenters will receive 3 nights hotel and a conference pass. Visit the Open Call page for detailed terms and conditions. See last year’s open call presenters and topics.

    Save $500 + one night hotel at MIX11 – register by Feb 11

    MIX11 registration opens in late January with a special offer for early birds – register by February 11 and save $500 on your conference pass, and receive one free night hotel when you book two or more nights at the Mandalay Bay. Join the MIX email newsletter and be among the first to learn about open registration, special offers, speakers and content for this year’s event.

    MIX11 event details


    April 12-14, 2011; MIX Boot Camps on April 11


    Mandalay Bay, Las Vegas


    Full Price Conference Pass - $1395
    MIX Boot Camps - $295

    More Info:

  • Palermo4 on MSDN

    Top 4 Blog Posts in 2010



    1. For the Web Forms developer who codes to the HTTP pipeline, check out how to extend HttpRequest with AJAX extension methods.
    2. Especially when developing for Web Sites, learn how to improve scalability and performance by defining “no-compile” web forms.
    3. Simple code sample for returning the contents as a string of an embedded text file (.txt, .xml, .css, etc…).
    4. Most popular of them all – code sample for “rewriting” the FindControl method of the Control class in ASP.NET Web Forms.
  • Palermo4 on MSDN

    Bitly Tweeter Updated



    The latest update to Bitly Tweeter allows for a default post format of the tweet.  Customization of the tweet can still be done when the blog post is published.

    If you are using Windows Live Writer for authoring your blog posts, then you owe it to yourself to get the most recent update of Bitly Tweeter!

  • Palermo4 on MSDN

    Bitly Tweeter Debut


    For bloggers who use Windows Live Writer and Twitter, you might be interested in checking out the Bitly Tweeter plug-in by Dan Waters.  This plug-in automatically tweets with a shortened link pointing to your blog when it is published.

  • Palermo4 on MSDN

    A Better FindControl Method


    For ASP.NET web forms developers, this is a handy extension method of the Control class that returns a strongly-typed control instance from a deep recursive search at any point in the control tree hierarchy:

    public static partial class ControlExtensions
        public static T FindControl<T>(this Control currentControl, string id) where T : Control
            if (id.Equals(currentControl.ID, StringComparison.OrdinalIgnoreCase))
                // return control calling this method
                return currentControl as T;
            // initialize potential "found" control to null
            T potentialFoundControl = null;

            foreach (Control childControl in currentControl.Controls)
                // recursive call to each child control  
                potentialFoundControl = ControlExtensions.FindControl<T>(childControl, id);
                // if result is not null, match has been found, break the loop
                if (potentialFoundControl != null) { break; }
            return potentialFoundControl;
        }// method
    }// class
  • Palermo4 on MSDN

    Get Embedded Resource as String


    Here is a utility method for returning any embedded resource content as a string:

    public static partial class Tools
        public static string GetEmbeddedContent(string resourceName)
            Stream resourceStream =
    .GetManifestResourceStream(resourceName); string content = null;
    using (StreamReader reader =
    new StreamReader(resourceStream))
    content = reader.ReadToEnd();
    } return content; } }
  • Palermo4 on MSDN

    Increase Web Site Scalability Using CompilationMode


    Did you know that ASP.NET Web Sites allow developers to configure whether a page compiles or not.  Consider the following page directive:

    <%@ Page Language="C#" CompilationMode="Never" %>

    Setting the CompilationMode attribute to Never will disallow code on the page.  It will also prevent compilation to an assembly.  These pages can contain server controls or Expressions such as $AppSettings and $ConnectionStrings.

    The main benefit is scalability.  In large web sites, this can avoid the need to compile high number of pages into assemblies.  Instead of compiling, these "no-compile" pages are processed by it's corresponding control builder which is preserved in memory for the life of the application.

    You can also let ASP.NET determine if a page qualifies for "no-compile" automatically by making the following setting in web.config:


  • Palermo4 on MSDN

    AJAX Extension Methods


    Although the ScriptManager has a property named IsInAsyncPostBack to determine an AJAX call, the control is scoped to the page it is contained in.  If writing code in a custom HTTP module, what if I need to know in the BeginRequest event whether the current request is AJAX or JSON?

    How nice it would be to simply ask the request if it is in the context of an AJAX or JSON call.  In Visual Studio 2008/2010, I can do just that.  With extension methods, I can add two new behaviors to the HttpRequest object.  Here are my desired methods:

    namespace Palermo4.Web.Extensions
        public static class WebExtensions
            public static bool IsJson(this HttpRequest request)
                return request.ContentType.StartsWith("application/json",
            public static bool IsAjax(this HttpRequest request)
                return (request.Headers.Get("x-microsoftajax") ?? "")
                    .Equals("delta=true", StringComparison.OrdinalIgnoreCase);

    The above methods simply return whether the content type of the request matches application/json (JSON call) or x-microsoftajax (AJAX call).

    To make use of my new methods in the global.asax, I need to add using statement for the namespace the extension methods are contained in.

    using Palermo4.Web.Extensions;
    public class Global : System.Web.HttpApplication
        protected void Application_BeginRequest(object sender, EventArgs e)
            if (!Request.IsAjax() && !Request.IsJson())
                // this is not an AJAX or JSON request

    I can also make use of this namespace in my web.config file as follows:

            <add namespace="Palermo4.Web.Extensions" />

    Now I can use my methods in any page as seen below:


  • Palermo4 on MSDN



    In one of my earliest blog posts ever, I made an observation about how Microsoft employees use the word 'so'.  So in honor of that blog post, I plan on acclimating to the machine with my own overuse of the word.

    I am so thrilled to announce that I am now employed by Microsoft as a Developer Evangelist.  My geographic area of coverage includes Arizona, Colorado, New Mexico, Utah, and southern Nevada.  So that means I get to work with great community leaders.  It also means I get to work with awesome people inside Microsoft.  I look forward to meeting so many more people as I grow into my role.

    So why this blog?  I have a blog at, and I blog at  So why another blog location?  This blog will be my new home for technical blogs.  The other blog sites will continue to function for non-technical content.  So with the exception of this post, all forthcoming blog posts will be technical in nature and likely contain much code.

    So, any comments?


  • Palermo4 on MSDN

    CNN Report: Arizona Desert Getting Cooler? [] more
Page 17 of 19 (183 items) «1516171819