Archives

Archives / 2006 / April
  • WebDialog 1.0.4 released

    WebDialog 1.0.4 has been released.

    The main new feature in this release is the state of the dialog (visibility, size and position) being remembered on post back. Also new is preliminary support for working within Atlas' UpdatePanel control. Note that this support won't effect regular ASP.NET 2.0 websites.

    What's New:

    • New Feature - Visibility, size and position state posted back from client.
    • New Feature - Preliminary Atlas support.
  • Testing if a ContentPlaceHolder is Empty

    K. Scott Allen, one of the many Scotts who seem to develop in .NET, has written a comprehensive article called Master Pages: Tips, Tricks, and Traps that looks at the new ASP.NET 2.0 feature. I use a couple of those features myself to handle page titles and descriptions, and I highly recommend it to anyone planning to use master pages in the near feature.One trick that I’ve found useful and that isn't in the article is how to modify master page content depending upon whether a ContentPlaceHolder has any content.For example you might have a ContentPlaceHolder on your master for related pages. To make it easier to later modify your design later you want to put the HTML for the container and title in the master, rather than every individual page.

    <div id="divRelatedPages" runat="server">
        <h3>Related Pages...</h3>
        <asp:ContentPlaceHolder ID="cphRelatedPages" runat="server" />
    </div>

    Unfortunately doing it this way will leave a box and title without anything else on a page that didn’t include any related links. The fix to this problem is testing if the ContentPlaceHolder has any content, hiding the divRelatedPages control and title if it doesn’t.To make this test easy I’ve created an IsControlEmpty method. The code inside it is quite simple. It returns true if the placeholder has no child controls or if it has just one child LiteralControl that contains nothing that whitespace. A blank LiteralControl is what is created when an auto-generated placeholder is left empty.

    public static bool IsControlEmpty(Control control)
    {
        if (control == null)
            throw new ArgumentNullException("control");
     
        ControlCollection controls = control.Controls;
     
        // control has no children
        if (controls.Count == 0)
        {
            return true;
        }
        else if (controls.Count == 1)
        {
            LiteralControl staticContent = controls[0] as LiteralControl;
     
            // control only has a literal child which is either empty,
            // or contains nothing but whitespace
            if (staticContent != null)
            {
                if (string.IsNullOrEmpty(staticContent.Text))
                    return true;
                else if (StringUtils.IsWhiteSpace(staticContent.Text))
                    return true;
            }
        }
     
        return false;
    }
     
    public static bool IsWhiteSpace(string s)
    {
        for (int i = 0; i < s.Length; i++)
        {
            if (!char.IsWhiteSpace(s[i]))
                return false;
        }
        return true;
    }

    Now simply pass the placeholder control to the method and hide divRelatedPages based on the result.

    if (ControlUtils.IsControlEmpty(cphRelatedPages))
        divRelatedPages.Visible = false;
  • Boot Camp: Hurting Mac Developers?

    Apple’s announcement and release of Boot Camp, a utility allowing the dual booting of Windows on Intel-based Mac hardware has certainly caused quite a stir, and for good reason. These are some thoughts on what Boot Camp will mean for those with a proclivity for one button mice and grayscale images. In particular, the effect of Mac users increased accessibility to Windows software on Mac developers.

    Mac Users

    This release is obviously good news for existing Apple users. With Intel Macs now able to run Windows the barrier to running Windows applications has fallen dramatically. A $199 Windows license is a lot less than a $1000 PC. Boot Camp means Apple users will now have easy access to Window’s huge library of applications and games, some of which previously wouldn’t have had an equivalent on Mac because of Apple’s smaller market share.

    Apple Computers, Inc

    Apple will also see benefit from Boot Camp, I believe in the form of a slow steady growth in market share. John Gruber wrote an excellent post looking at Boot Camp’s release and made an interesting statement about how Mac’s are no longer different, they’re special. They can run both Windows and OS X. The enthusiast running Windows, who previously would never have considered a Mac because it didn’t have X game or Y application, would now give buying Apple hardware some serious consideration. I expect this will be a gradual process, happening as user’s look around when upgrading their current computers, rather than a sudden rush.

    While the bump in growth from Boot Camp could be slow, I think it will be very good news for Apple as these users will be the best kind to get. Enthusiasts are the people that run websites and have (popular) blogs. They are the movers and shakers of the Window’s world. Tyhco and Gabe of Penny-Arcade for example both recently purchased Macs and have waxed lyrical on the subject to an audience of god knows how many people. Having influential customers is never a bad thing.

    So is Boot Camp a home run for the world for the world of Mac computers? In my opinion, not quite.

    Mac Developers

    While the lower barrier for Apple user’s to run Windows applications will lead to growth in the share of users running Apple hardware, overall the effect on Mac developers will probably negative. The reason? In a word: Competition.

    Apple has a significantly smaller install base than Windows, which translates into a smaller potential market for software that targets OS X. To Mac users the most obvious effect of the smaller market is that software available on Windows, some niche application for example, might not be available for Macs. The market just isn’t large enough to make developing it on OS X commercially viable.

    Since there are no Mac developers producing those very niche market applications there is no harm done by making it easier for users to use with Windows. However the other effect of the smaller market is that where software applications are available on OS X, the range of choice is not as great as it is on Windows.

    In other words there are less developers competing with one another. Where there could be dozens of an application on Windows for some specific task, there may only be a handful on OS X; and where there are only a handful on Windows there may be just one choice on for the Mac.

    Where previously a Mac developer might have been able to charge a premium for his software, possibly because his was the only one for Macs that had a certain feature, he will now have to be much more aware of what the price of the equivalent software on Windows is. Charge too much and he’ll lose sales as user’s who were previously restricted to Mac software by the high cost of buying a separate PC will now buy the Windows version instead. Without the previous premium will he be able to survive? Is it worth him to continue making software targeting OS X given its small install base and the increased competition from the comparatively cut throat world of Windows applications? Time will tell.

    Final thought:

    Apple hardware is now special. It can run on both Windows and OS X. But by the same logic that also means Windows software is special because it can run on both types of hardware. Supposing Apple continues to improve its integration with Windows beyond dual booting to the point where Windows software can run within OS X, where does that leave Mac software?

  • WebDialog 1.0.3 released

    Version 1.0.3 of WebDialog has been released. This release is primarly focused on bug fixes.

    Also included is the source code of 3 example websites: Callback sample, Modal sample and IFrame sample. The samples can also be viewed on the updated WebDialog online demo webpage.

    What's New:

    • Other - Added three sample websites to the WebDialog download: Callback sample, Modal sample and IFrame sample.
    • New Feature - Added an IsVisible() function to the WebDialog JavaScript object.
    • Bug Fix - Fixed the page overlay not hiding with the dialog if Show() was called multiple times.
    • Bug Fix - Message of exceptions thrown during a callback are now displayed in the dialog. Future versions will allow this to be customized in a template.