Maarten Balliauw {blog}

Web development, NuGet, Microsoft Azure, PHP, ...


Excel, OpenXML and PHP

Yay! My new article on Excel, OpenXML and PHP has just been released in php|architect! A copy-paste action from

"A few months ago, Microsoft released Office 2007, a version of their office suite that generates open source documents. Here, Maarten Balliauw gives an overview of the history and the politics surrounding the release before moving on to introduce his PHPExcel project, an early adoption of Microsoft's OpenXML API that enables Excel 2007 spreadsheets to be generated with PHP."

ASP.NET 2.0 Event Validation

Event Validation is a new feature in ASP.NET 2.0 which provides an additional level of checks on postback actions. It verifies whether a postback from a control on client-side is really from that control and not from a malicious person trying to break your application.

Even if you forget to add security checks of your own, ASP.NET provides this functionality, because this feature is enabled by default. Sometimes, it is safe to turn this of, but Microsoft tries to have developers turn this of when they know what they are doing.

Unfortunately: I came across Event Validation… A user control on a master page convinced ASP.NET that a postback within that same user control was unsafe, resulting in the following error:

"Invalid postback or callback argument.  Event validation is
enabled using <pages enableEventValidation="true"/> in
configuration or <%@ Page EnableEventValidation="true" %>
in a page. For security purposes, this feature verifies that
arguments to postback or callback events originate from
the server control that originally rendered them.
If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method
in order to register the postback or callback data for validation."

There are some options to overcome this… One is to add a EnableEventValidation="false" in your @Page directive, another is to globally disable this in your Web.config (don’t!). The best solution, however, is telling ASP.NET to allow events from your user control’s inner controls, by adding the following snippet of code in the user control:


protected override void Render(HtmlTextWriter writer)
    // Register controls for event validation
    foreach (Control c in this.Controls)


Team Foundation Server tools linkdump

Currently, I'm playing around with TFS (Team Foundation Server), and here's just a quick linkdump of some TFS tools, mainly on CodePlex.

Workaround for PHP file_exists on ZIP file contents

Recently, I was writing some PHP code, to check if a specific file existed in a ZIP file. PHP has this special feature called "stream wrappers", which basically is a system which enables PHP to do I/O operations on streams.

A stream can be a file, a socket, a SSH connection, ... Each of these streams has its own wrapper, which serves as an adapter between PHP and the underlying resource. This enables PHP to do, for example, a file_get_contents() on all sorts of streams.

Assuming regular PHP file functions would be sufficient, I coded the following:


if (file_exists('zip://')) { ... }


Knowing that the file readme.txt existed in the ZIP file, I was surprised that this function always returned false... What was even more surprising, is that a file_get_contents('zip://') returned readme.txt's data!

The reason for this is unknown to me, but I've written a (dirty) workaround that you can use:


function zipped_file_exists($pFileName = '') {
    if ($pFileName != '') {
        $fh = fopen($pFileName, 'r');
        $exists = ($fh !== false);

        return $exists;

    return false;


Scalable Apps with Asynchronous Programming in ASP.NET

A while ago, I posted about the DevDays, and some interesting sessions I took. One of these sessions was "Scalable Apps with Asynchronous Programming in ASP.NET", by Jeff Prosise. Searching the Internet, I found that Jeff also published an article on this subject on MSDN, which can be found on the following URL: