ASP.NET __doPostBack is not defined

Wow! What a fucking morning! I came into work today to get something working. That something should have been real easy to do (you don’t need to know what it is, just that it was going to be real easy). I exported a copy of the core code, associated it to my website so that I could run the debugger through it and make my changes. This was going to form the basis of the next version of the core code.  But for some reason when I hit any button I received __doPostBack is not defined error in the javascript error console of Firebug. Continue reading ASP.NET __doPostBack is not defined

ASP.NET ValidationSummary – Stopping the scroll back to top

I came across an issue today with a validation summary form on a sign up form.  The form was at the bottom of a page containing much text…well that’s what was in the design and it will probably turn into “Please sign up here” once the client get’s their hands on it.  But that’s par for the course.

Now because the sign up form was below the lorem ipsum text in the design, I also placed the validation summary below this.  But this causes a small technical issue when you hit the submit button and some of your elements do not validate, the whole page scrolls to the top.  Not very easy for a user to see what went wrong without scrolling back to the form.

Why does this happen?  Microsoft in their infinite wisdom have placed some really annoying javascript into their validation code.  If you inspect the shite that Microsoft pumps into the page with a form and validation controls, you may find (there is a lot of code) a window.scrollTo(0,0) line buried away.  This of course scrolls your window back to the top.  For most cases this will be fine, as most cases the form is not preceded by craps loads of text, and your validation summary will either be at the top, or be as close as dammit to it.  Not in my case, and not as it seems many others.  So I had to find a solution. Continue reading ASP.NET ValidationSummary – Stopping the scroll back to top

Uploadify your large files in .NET

With the increase in memory for servers and the subsequent decrease in price, you’d have thought .net would have had a better way to upload files of a larger persuasion built in.  Nope!

So when I found Uploadify I thought, ooh that’s nice!  And I have to thank William Duffy (again!!) for this find.  It gives you a real nice uploading widget thing without the dreaded postback.  As it uses Adobe Flash to achieve this, it means you can concentrate on other things, like the CSS.  It’s also VERY lightweight, only 30kb for the min’d javascript and the swf file.  Well done lads. Continue reading Uploadify your large files in .NET

Facebook’s Graph API and

Am enthralled with the new Facebook API. It’s awesomely simple to use. I mean really simple to use. They have changed the authentication process as well, and fuck me it’s so so much simpler than before.

Previously I integrated Facebook Connect with iMapFlickr, to allow uses to post to their own wall automatically, saying that they had created a new map about cheese and bunny rabbits.  But it was such a pain in the ass to use.  But I did it, although am a little balder for it!!

Facebook – now with added thought

The new Facebook API throws essentially everything they have done out the window, rewriting everything and using oAuth to authenticate a user.  They have even made oAuth simpler, which leads me to think it’s not really the full oAuth specification, but hey it works nicely!

But one thing they forgot to do was let .NET developers in on the secrets.  They released all the libraries and code and examples for other programming languages but .NET is sitting outside of Facebook Towers crying, not being allowed into the party as it has “Microsoft” as part of it’s name.  Fuckers.  I sold me soul to Microsoft a long time ago, so I have spent some time working this out. Continue reading Facebook’s Graph API and

File uploader with javascript extension validation

I was recently creating a form that needed to upload an image only to an email handler.  The file would then get emailed to the client.

The way that we have always worked this, is the fileupload control posted back to the server and checked the fuImage.HasFile and then fuImage.FileName, maybe even using the FileInfo class to let it grab the extension, and check it against a list.

But I realised that is real old school, and with the loveliness of jQuery and regular expressions. Again the internet failed me almost, as there are not really good posts or helpers out there that do this. Everything that appears seems to be out of date, or does something similar but not what am wanting. Well here is a quick script to check the file extensions and inform the user if the file is an image or not:

$(document).ready(function () {

        $("#btnRegister").click(function () {
            // check if the file you are going to upload is an image or not.
            var filePath = $("#fileUpload").val();
            filePath = filePath.replace(/^\s|\s$/g, "");
            if (/\.\w+$/.test(filePath)) {
                var m = filePath.match(/([^\/\\]+)\.(\w+)$/);
                if (m) {
                    if (m[2] == "gif" || m[2] == "jpg" || m[2] == "png" || m[2] == "bmp") {
                        return true;

            alert("Please make sure you upload only pictures.");
            return false;



And that’s it. You can quite easily change the file extensions here to suit your needs, even try and do something fancy with call backs to the server with the file extension so you can read a dynamic list or from a config file or something, how should I know that’s you job fs!!

Using a Bespoke CDN with WordPress

I have been helping a friend with his website lately and again it started to slow down, due to the massive traffic the site gets.  The last time I checked the stats Elephant Journal get’s 250,000 visitors a month with approximately 450,000 page views!  That’s quite a busy wee site.

A while back we moved some of the static files off site, and that helped massive get the site another 70,000 visitors a month – people didn’t drop out or bounce while they were waiting for the site to load.  This was real easy to do, and just meant we pointed the URL of the file to the new server.  But now the site is slowing again, and I believe it is due to the massive number of images that get downloaded.  So how do you move all these images off site and update all the URLs?  WordPress comes to the rescue…but you need to do some coding. Continue reading Using a Bespoke CDN with WordPress

Google Maps API v3 – Multiple Markers, Multiple Infowindows

Like many of you out there that use Google Maps, when v3.0 of it came out you jumped at the chance to use it!  But I couldn’t get the multiple markers, multiple info windows to work, no matter what I found on Google’s site.

Searching got me to this blog:

And it states this guy is writing a book on this very subject.  So this should have the answer.  Well bollocks it did!  Stop writing your book now matey! Continue reading Google Maps API v3 – Multiple Markers, Multiple Infowindows