Various ASP.net Links Volume 2, SourceGrid, H.264 in Flash

A few days ago, I’ve posted a list of links to solve various issues I ran into while creating a site. Now, here is yet another list for another set of issues. By the way, I usually use Twitter as my scratchpad when I stumble across new links, so feel free to follow me.

  • Automating aspnet_compiler
    • Usually, I use the “Publish Web Site” Function in Visual Studio to Publish my Web Project
    • However, for build scripts on my non-Visual Studio Build Server, I need to use aspnet_compiler
  • HttpModules instead of Global.asax
    • Sounds a lot more complicated than it is
    • Allows to be more flexible than with Global.asax
  • App_Offline.htm
    • Useful to display a “This Application is currently undergoing maintenance” message while you are just re-uploading a new version of an application
    • Also contains a Bonus hint regarding Internet Explorers Friendly errors

And as a Bonus:

  • SourceGrid
    • A simple Grid that reminds me of Delphi’s StringGrid, except that it’s a bit more flexible
    • The standard WinForms DataGridView is not really working for me when I want to add images, buttons or stuff like that
  • Flash and H.264
    • Since some time, Flash can play back H.264 videos. Unfortunately, everyone just calls it “Flash 9 Update 3”, which is not helpful when you want to programmatically check if the Flash Player supports H.264.
    • So to clarify this once and for all: The First version of Flash to support H.264 is 9.0.115

Gracefully handling HttpRequestValidationException with ASP.net AJAX

In the various ASP.net links i’ve posted earlier, I also had one regarding the graceful handling of HttpRequestValidationException. The idea of manipulating the Response to deliver a nicer error page is good, but there is one problem: ASP.net AJAX will just show a Popup instead.

HttpRequestValidationException AJAX Popup
HttpRequestValidationException AJAX Popup

So, how can we handle THAT gracefully? If you are thinking: Just handle AsyncPostBackError in the ScriptManager, you’re wrong, as this error handler is not called for HttpRequestValidationException as it’s caught outside of the page. You have to catch this error Client-Side using JavaScript.
There is an article on ASP.net AJAX which deals exactly with this: Customizing Error Handling for ASP.NET UpdatePanel Controls. At the bottom of the article, you’ll find the client-side JavaScript for it.
I’ve combined it with the “Disabling a Button in an AJAX UpdatePanel” method, so my JavaScript within my .aspx Page looks like this now. Needs some more tweaking in the status-code, but you’ll get the idea. Also note the use of inline-ClientId at the bottom.

<script type="text/javascript" language="javascript">
var pbControl = null;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args) {
  pbControl = args.get_postBackElement();  //the control causing the postback
  pbControl.disabled = true;
}

function EndRequestHandler(sender, args) {
  pbControl.disabled = false;
  pbControl = null;

  if (args.get_error() != undefined)
  {
    var errorMessage;
    if (args.get_response().get_statusCode() == '200')
    {
      errorMessage = args.get_error().message;
    }
    else
    {
      // Error occurred somewhere other than the server page.
      errorMessage = 'An unspecified error occurred. ';
    }
    args.set_errorHandled(true);
    $get('<%= this.newsletterLabel.ClientID %>').innerHTML = errorMessage;
  }
}
</script>

Various ASP.net Links

Me and some friends are currently working on a little movie project, The Filthy Pumpkin Show. My job – apart from being the main script writer – is the website, which is a ASP.net based one.

So when building it, I stumbled accross a few questions, and here is my list of some helpful links.

  • Adding JavaScript Attributes to a Textbox
    • Simply adding onblur/onfocus to a asp:TextBox causes a Warning in Visual Studio
    • textBox.Attributes.Add does the trick
  • Gracefully handling HttpRequestValidationException
    • ValidateRequest is a great ASP.net function, but the Yellow Screen of death is not so nice
    • Warning: This does not work properly with AJAX. I have an UpdatePanel with a Textbox and when the user types HTML into the Textbox with the above soultion, then there will be an error popup. I’ll see on StackOverflow if there is a better solution…
  • Disabling a Button in an AJAX UpdatePanel
    • To prevent double-submissions when using ASP.net AJAX
  • Ajaxy Loadng Images
    • What does every Web 2.0 Website need, apart from a “BETA”-Banner? Of course: Spinning Circles when AJAX Stuff is happening!
    • This page generates a variety of those loading images

VisualSVN

Edit: This post was written when AnkhSVN 1.x was the current version. In the meantime, AnkhSVN was updated to 2.x and much improved. I use it in production on a system where I don’t have VisualSVN and it works extremely well now.

So, another item to mark “completed” in my always too long ToDo-List: Purchase a License of VisualSVN. Now, what took me so long? The existance of a good alternative – AnkhSVN.

Why did I switch? Because i was a bit unhappy with the overall stability of Ankh, since it has some problems actually tracking Solution changes. VisualSVN is “just” a TortoiseSVN Frontend, which means it leaves all the “heavy lifting” to a third-party tool that a) is installed on most Workstations anyway and b) that’s been tested and used by such a wide audience, it’s really rock-solid.

Now, AnkhSVN is certainly not a bad product, and the people behind it are serious about what they are doing, but having long-deleted files still in my SVN or getting the “Please Cleanup your solution” message get’s annoying after some time, but my biggest gripe is the property window. It’s nice that there is a nice window with Radio Buttons asking me which property I want to add. Unfortunately, there is no way to manually enter a property.

So, yes, VisualSVN is “just” a $49 TortoiseSVN Frontend (A frontend for a frontend, so to speak), but it’s neat Visual Studio integration really makes it worth the money for me. Their free VisualSVN Server is pure gold by the way, I absolutely love it 🙂

All your internet are belong to Google

Interesting:

11. Content license from you

11.1 You retain copyright and any other rights you already hold in Content which you submit, post or display on or through, the Services. By submitting, posting or displaying the content you give Google a perpetual, irrevocable, worldwide, royalty-free, and non-exclusive license to reproduce, adapt, modify, translate, publish, publicly perform, publicly display and distribute any Content which you submit, post or display on or through, the Services. This license is for the sole purpose of enabling Google to display, distribute and promote the Services and may be revoked for certain Services as defined in the Additional Terms of those Services.

11.2 You agree that this license includes a right for Google to make such Content available to other companies, organizations or individuals with whom Google has relationships for the provision of syndicated services, and to use such Content in connection with the provision of those services.

11.3 You understand that Google, in performing the required technical steps to provide the Services to our users, may (a) transmit or distribute your Content over various public networks and in various media; and (b) make such changes to your Content as are necessary to conform and adapt that Content to the technical requirements of connecting networks, devices, services or media. You agree that this license shall permit Google to take these actions.

11.4 You confirm and warrant to Google that you have all the rights, power and authority necessary to grant the above license.

GoodBye from my Harddrive, Chrome.

Update: It looks like Google admits their mistake and that they will change the EULA. Not that I believe them that it was a mistake (Just like Adobes “Mistake” on Photoshop Express…), but that’s one step in the right direction. Chrome is an excellent product even in the early stage, and it would be a pity it would be made useless through the EULA. Now, please just remove the unique Application ID and maybe think about changing the default behavior of the Omnibar as well.

Dr. Horrible Soundtrack available!

Finally, 6 Weeks after the release of Dr. Horrible’s Sing-Along Blog, the Soundtrack is available on the iTunes, and this time it’s also available for European Audiences!

The Soundtrack consists of 14 Songs, with a total length of 24:44 Minutes. Conveniently, it’s released in 256 kbit/s without DRM for 9.99 €. Sadly, the songs are not longer or otherwise different, but it’s still a must buy in my opinion as I really adore the project (did I mention it was one of about 12 different inspirations for us to do the Filthy Pumpkin Show?).

Also, more good news, according to the creators, the show should be available on iTunes for European Audiences as well soon, and the DVD Commentary makes progress. Yes, buying the Show, the Soundtrack AND the DVD may seem like “wasting” money, but I really think that the product deserves it – it is simply good, “honest” entertainment.