I was looking for a way to clear a textbox on focus in an ASP.Net application today and found some Microsoft examples using scripts in the Markup language and then referencing the script using the old onfocus="SomeFunction();". But then I found the best way that works easily and keeps the code in the code behind.
In the Page Load event of you page or of your Masterpage, place one line of code which adds an attribute to the textbox and you are finished:
As you can see, you can modify the attribute to contain an object event and then place any code within the value property to be executed. You can have as many attributes for as many objects as you like.