Saturday, October 15, 2005
Thursday, October 13, 2005
Easy Confirm Delete in ASP.NET. No code required!
I created this ickle JavaScript file (tested IE6 and Firefox) using non-intrusive, DHTML. As well as being simpler, you'll also get rid of all that old-style, heavy, spaghetti JavaScript that ASP.NET spits out all over your tidy HTML!
Instructions:
1. Paste the code below into a file called comdel.js
2. Add a link to it in your <head>
<script src="comdel.js" type=text/javascript></script>
3. Set CssClass="comdel" on any <asp:Button> or <asp:LinkButton> for which you require confirmation.
4. That's it! Never get bogged down in JavaScript attributes again.
function xPreventDefault(e) {
if (e && e.preventDefault) {
e.preventDefault();
}
else if (window.event) {
window.event.returnValue=false;
}
}
function xAddEventListener(el, evType, fn, useCapture) {
if (el.addEventListener) {
el.addEventListener(evType, fn, useCapture);
return true;
} else if (el.attachEvent) {
var r = el.attachEvent('on'+evType,fn);
return r;
} else {
el['on'+evType]=fn;
}
}
function xEventTarget(e) {
if (e && e.target) {
return e.target
}
else if (window.event && window.event.srcElement) {
return window.event.srcElement
}
else {
return null
}
}
function comdel(e) {
var el=xEventTarget(e);
if (!el) return;
if (!confirm('Delete this record?')) {
xPreventDefault(e);
return false;
}
}
function onLoad() {
if (!document.getElementsByTagName) return;
// Add event listener to all <a> where className includes "comdel"...
var all_a = document.getElementsByTagName('a');
for (var i=all_a.length-1;i>=0;i--) {
if (all_a[i].className.search(/\b ?comdel\b/) != -1) xAddEventListener(all_a[i],'click',comdel,false);
}
// Add event listener to all <input> where type='button'...
var all_input = document.getElementsByTagName('input');
for (var i=all_input.length-1;i>=0;i--) {
if (all_input[i].className.search(/\b ?comdel\b/) != -1) xAddEventListener(all_input[i],'click',comdel,false);
}
}
xAddEventListener(window,'load',onLoad,false);
Monday, October 10, 2005
Sunday, October 09, 2005
Monday, August 01, 2005
Witchery
Spent last night in the "Guard Room" at The Witchery in Edinburgh. This has gotta be Scotland's (if not the UK's) most superb hotel. When the receptionist told us "to follow that woman" to our room - we weren't prepared for the trek across the street, though a secret passageway and up a flight of Harry Potteresque spiral stairs that ensued! Sumptuous is too shallow a word for this place. Forgot my digital camera - but we bought a cheapy disposable, will upload some photos later - if any turned out! Have stuck one in of "The Secret Garden" where we had the most gorgeous food ever for now. Thanks to Lesley who surprised me with this for my birthday. Helped soften the blow!
Tuesday, June 21, 2005
Cove Boutique
Cove Boutique

