If it's ASP.NET you're using, you should stick to the ASP.NET forum as it has its own 'quirks'.

In your case, I am guessing that the actual rendered ID of the textbox control is not TextBox1. Do a view source and see for yourself. You will need to generate the call to the function in the codebehind or generate the javascript in the codebehind, because that's where you have access to the .ClientID property. (TextBox1.ClientID)