Getting a geocode easily and quickly that is accurate using Google Maps

Monday, May 26th, 2008

I have found that in some cases I just need a geocode for a map rather than creating some form of admin suite every time - I just need one or two locations that may be hard coded into the map.

There are a few out there but they don’t seem to just do what I want so I have created my own little Google Maps mash up thingy. It uses Google Maps version 2 and has the small Google map search. Just stick in a postcode or location etc, and then drag the pin exactly where you want it and that’s it!

Geocoding the easy way:

http://geocode.jamiehinton.co.uk/

Creating a scheduled job using .NET - bit like a cron job

Sunday, May 25th, 2008

Will review these solutions:

http://www.codeproject.com/KB/dotnet/ABTransClockArticle.aspx

http://www.codeproject.com/KB/cs/tsnewlib.aspx

IE7 evalScripts with Prototype throws an error

Thursday, May 22nd, 2008

This is yet anther IE bug I have found whilst doing a lot of AJAX stuff with prototype recently. If you make and AJAX request such as AJAX.Update(blah blah and you set evalScripts: true then IE7 will throw a wobbly (great).

Basically if the JS has comments around it then IE blows up. I found this a useful link:

When using Ajax.Updater with the option evalScripts:true like:

  new Ajax.Updater( table_id+'tbody', '/someurl', {
    parameters : { 'table_id':table_id },
    evalScripts : true
  });

and response of /someurl contains the following script:

<script language="JavaScript" type="text/javascript">
<!--
alert( 'Hello' );
// -->
</script>

IE7 throws an error “Syntax error” in line 212 of prototype.js version 1.5.0 in function evalScripts.

If you try a non-commented script like:

<script language="JavaScript" type="text/javascript">
alert( 'Hello' );
</script>

it works. Firefox works whether the script is commented or not.

I am currently using JSF and Facelets for my web app that adds the comments around the JS for you - PAIN IN &^%$£

Not got a solution yet for JSF!

UPDATE!!

We tried to change myFaces so that it did not render the comments but thought that it was a bad idea and back tracked!

So the fix had to be in the JavaScript. We added the following to the Prototype class:

exec: function(code) {
  if ((code += '').blank()) return;
  var script;

  if (document.body) {
    script = new Element('script', { type:'text/javascript' });
    try {
      script.appendChild(document.createTextNode(code));
    } catch (e) { script.text = code; }
    ($$('head').first() || $(document.documentElement)).insert(script);
  }
  else {
    var scriptId = '__prototype_exec_script';
    document.write('<script id="'+ scriptId +'" type="text/javascript">'+ code +'<\/script>');
    script = $(scriptId);
  }
  script.remove();
  script.text = '';

},

And then changed where it evals the scripts to use this method instead. This does mean we cannot easily just upgrade the version of prototype we are using but to be honest I would rather it worked in the first place!

Going to have a look at iGoogle widgets - lets have a go with one

Wednesday, May 21st, 2008

The developer central is here:

http://code.google.com/apis/igoogle/

A beginners guide will follow soon.. I promise!

AppSettings ASP.NET & MasterPages

Wednesday, May 21st, 2008

You don’t always have to use the old:

ConfigurationManager.AppSettings["whatever"]

In a master page you can also use a bit of short hand:

<%$ AppSettings:whatever%>

Saves some typing a suppose…

Selenium test suite

Wednesday, May 21st, 2008

I need to perform many tests in one go one a few of my sites - so setting up a test suite with selenium

http://www.jamesnetherton.com/blog/index.cfm/2007/7/2/Creating-a-Selenium-test-suite

Visual Studio 2008 Colour schemes

Tuesday, May 20th, 2008

The standard white background is a little boring and if you are looking at it all day it gets a bit bright so I thought I would have a change.

I found a few that I liked from here and here

I took one and altered it to my liking.

ID mangling in ASP.NET MasterPages

Monday, May 19th, 2008

This is fine if you just let .NET generate your client side script - but what if I want to write my own? What options do I have?

  1. Alter all your ID’s in your script as they will always be mangled the same! - I would rather not thanks..
  2. Change the ID’s in your script at runtime - not great but better
  3. Got any better ideas?

VB I know but you still get the idea:

Dim script As String = “[Label1ID].innerHTML = ‘boo!’;”
Dim scriptKey As String = “SayBoo”
Dim addScriptTags As Boolean = True

Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)

script = script.Replace(“[Label1ID]“, Label1.ClientID)

ClientScript.RegisterStartupScript( _
Me.GetType(), scriptKey, script, addScriptTags _
)

End Sub

Thanks to: http://www.odetocode.com/articles/450.aspx

Meta Tags in a .NET Master Page

Monday, May 19th, 2008

At first I thought the best approach would be to use a content place holder but then I thought no this is .NET and the framework should have a way to let me do this a little more elegantly (I do like my code to be elegant)

So the way I plumped to do this was to use the HtlmHead object. The MasterPage exposes the Head element and you can add attributes like so:

HtmlHead head = (System.Web.UI.HtmlControls.HtmlHead)Header;
HtmlMeta keywords = new HtmlMeta();
keywords.Attributes.Add(”name”, “keywords”);
keywords.Attributes.Add(”content”, Product.Keywords);
head.Controls.Add(keywords);

Dead easy really. Whilst Googling I did find some other useful info on MasterPages - fixing those mangled ID’s in master pages etc!

Simpler:

HtmlMeta tag = new HtmlMeta();
tag.Name = "description";
tag.Content = "My description for this page";
            Header.Controls.Add(tag);

Load testing a website?

Thursday, May 15th, 2008

http://www.webload.org/