When using ajax aspx pages use RegisterStartupScript. Using techniques such as response.write to add scripts on an event postback will not render the page correctly.