There can be a few corrections first of all you need document.ready event or another helper function (i changed to a helper function due to asp.net's clientid thing) and then you have to stop button posting back your page.