March 2010
M T W T F S S
« Dec   Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

Set dropdownlist

function setDropDownList(elementRef, valueToSetTo)
{
var isFound = false;

for (var i = 0; i < elementRef.options.length; i++)
{
if (elementRef.options[i].value == valueToSetTo)
{
[...]

Add, remove event in Google map

// add

var map = new GMap2(document.getElementById(”map”));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
GEvent.addListener(map, “click”, function() {
alert(”You clicked the map.”);
});

// remove

function MyApplication() {
this.counter = 0;
this.map = new GMap2(document.getElementById(”map”));
this.map.setCenter(new GLatLng(37.4419, -122.1419), 13);
var myEventListener = GEvent.bind(this.map, “click”, this, function(overlay, latlng) {
if (this.counter == 0) {
[...]

String.Format() In JavaScript like C#

function StringFormat(str)
{

for (i = 1; i < arguments.length; i++)
{
str = str.replace(’{’ + (i – 1) + ‘}’, arguments[i]);
}
return str;
}

example using:
var greeting = format(‘Hello {0} & {1} ‘, ‘John’, ‘Jane’);

ref: http://xneuron.wordpress.com/2006/09/29/stringformat-in-javascript-as-in-c/

javascript get client ID by endswith string

String.prototype.trim = function()
{ return (this.replace(/^[\s\xA0]+/, “”).replace(/[\s\xA0]+$/, “”)) }

String.prototype.endsWith = function(str)
{ return (this.match(str + “$”) == str) }

String.prototype.startsWith = function(str)
{ return (this.match(”^” + str) == str) }

function getClientIdByEndsWith(strid)
{
var count = document.forms[0];
var i = 0;
var eleName;
var found = false;
[...]

Firebug on google chrome

+

Compatible with all major browsers: IE6+, Firefox, Opera, Safari and Chrome

ref: http://getfirebug.com/releases/lite/chrome/

Sql Server Tip 3

Tip#3: Try to use CAST instead of CONVERT. CAST is ANSI-92 standard but CONVERT works in MS SQL server only. Also, some CONVERT styles may be deprecated in future MS SQL releases.