neat javascript syntax
I was talking with Darren earlier after he uncovered a neat javascript syntax. Besides being fairly neat looking, I also think it would be incredibly useful when using RegisterArrayDeclaration method for customizing instances of controls that use script.
I was just testing it a little bit, and this is the kind of syntax that you can use with it.
<html><body><form method="get" action="foo.html">
<script language="javascript">
// This is the result of RegisterClientScriptBlock
function Foo_Init() {
for( var i = 0; i < Foos.length; i++ ) {
// regardless of the number of properties being pulled,
// it's always a simple i++ to the next item
var fooProperties = Foos[i];
// note the complete lack of of magic numbers to get the properties out.
// the order of the items in the array declaration are irrelevant
// and this is much more readable
var fooInstance = document.getElementById(fooProperties.ID);
fooInstance.innerHTML = fooProperties.html;
}
}
</script>
<span id="FooInstance1"></span>
<br>
<span id="FooInstance2"></span>
<script language="javascript">
// This is the result of RegisterArrayDeclaration
// Each server control simply wraps its properties in { .. } to indicate an item block
var Foos = new Array( {ID:"FooInstance1", html:"I'm a Foo!"}, {ID:"FooInstance2", html:"I'm a \"Foo\" Too!"} );
</script>
<script language="javascript">
// This is the result of RegisterStartupScript
Foo_Init();
</script>
</form></body></html>
This is a great syntax. It's my new standard