By coincidence I noticed a method I’ve never seen before on the ClientScript property of the page class in ASP.NET 2.0. It’s called something as cryptic as RegisterExpandoAttribute and it’s very useful.
Here are two examples – one where a property is set on a server-control and one on a HTML element otherwise invisible to the code-behind.
Page.ClientScript.RegisterExpandoAttribute(txtPassword.ClientID, "value", "britney");
Page.ClientScript.RegisterExpandoAttribute("maintable", "background", "red");
var txtPassword = document.all ? document.all["txtPassword"] : document.getElementById("txtPassword");
txtPassword.value = "britney";
I think where this really rocks the most is the ability to control regular HTML elements that hasn’t got the runat=”server” attribute. Those elements have always been invisible to the code-behind and now you have direct server-side access to their properties. The method doesn't give you anything you couldn't do before, but it makes it so much easier and cleaner.