The above code works. Make sure if you have user ScriptManager.RegisterStartupScrip anywhere other part of the page then you have terminate Javascript code with ;. If inline javascript fails, no other function is called.
Refer: ScriptManager.RegisterStartupScript code not working - why?