Automatically adding ValidatorCalloutExtenders to your validators
I recently had to work on a pretty big ASP.NET page with lots of fields that needed to be validated.
We thought it would be cool if we used the AJAX Toolkit ValidatorCalloutExtender control on the validators to keep the validation inline and concise.
To quote from the AJAX Toolkit page:
ValidatorCallout is an ASP.NET AJAX extender that enhances the functionality of existing ASP.NET validators. To use this control, add an input field and a validator control as you normally would. Then add the ValidatorCallout and set its TargetControlID property to reference the validator control.
Because we had over 30 text fields, it would have been really tiresome to add extenders manually to each of the validators. So a way to attach them dynamically was needed.
Fortunately, this is pretty easy to do by iterating through the Page.Validators collection, dynamically creating ValidatorCalloutExtender controls and adding them to the Page.
Challenges
- The first problem I had was an error that occured when trying to dynamically add controls to the Page.Controls collection: (more…) Bookmark on del.icio.us
How to auto zoom and auto center Google Maps
This post discusses how to auto center and auto zoom a Google Map to display all of the markers optimally.
In order to get accomplish this, you have to calculate the center point and zoom level manually via code. Fortunately this is pretty easy to do, you just need to calculate the minimum and maximum latitude/longitude of all of your markers and then get the center point of the resulting area (which will be a rectangle). (more…)
Bookmark on del.icio.usGenerating a transparent GIF image using C#
Problem:
There is apparently no easy way to generate a transparent GIF image using the .NET framework. Microsoft provided a method in the Bitmap class called MakeTransparent() but it doesn’t work for GIFs, it only seems to work for PNGs.
To create a transparent GIF you need to recreate the color table of the image using Imaging APIs, as detailed in this KB article . Unfortunately, this can be pretty slow for an ASP.NET Web application, and it has a lot of overhead, so I needed an alternative. (more…)
Bookmark on del.icio.us