runnane Everything that matters ++

18Jul/080

Checking checkboxes, not always a breeze

So, I was sitting here and debugging some code for more than three hours. And finally, I figured it out: You cannot set a checkbox as checked until you have appended it to a container.

Code that does not work:

var newEl = document.createElement('input');
newEl.type = 'checkbox';
newEl.value = 'yes';
if(value == '1'){
   newEl.checked = "checked";
}
                               
$('AttributeValue_Container').appendChild(newEl);

Working code:

var newEl = document.createElement('input');
newEl.type = 'checkbox';
newEl.value = 'yes';

$('AttributeValue_Container').appendChild(newEl);
if(value == '1'){
  newEl.checked = "checked";
}

Really annoying ;)

Filed under: HTML/JS No Comments
21Mar/080

Hardboot linux machine from console

http://blog.air4web.com/linux-force-reboot.html

Pretty handy when my server hangs on umounting a drive:

echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger

Filed under: Linux No Comments
5Mar/080

HttpContext.Current.Items

Great method for sharing info in different layers in ASP.NET without passing anything between them.

http://www.mikeduncan.com/3-hot-uses-for-httpcontextcurrentitems-they-wont-tell-you-about

Filed under: .NET No Comments