document.all
is a non-standard extension that even Microsoft removes it from IE.
So don't use it! Use
document.getElementById('TextBox2')
. It's standard and supported by every browser...
It became obvious - from comments - that the source of the HTML is an ASP.NET page.
ASP.NET creates it's own ids - based on what you entered - to ensure unique id fro page.
For details you may see
INamingContainer[
^].
It means that the id you give (TextBox2) is valid only for server-side. To access the very same object on client write your JavaScript like this
document.getElementById('<%=TextBox2.ClientID%>')