In case we have an update panel and we need to register a script on partial postback it should be done through script manager. So the code would be.
ScriptManager.RegisterClientScriptBlock(Control, Type, String, String, Boolean)
ScriptManager.RegisterClientScriptBlock(control, Type, key, script, add script tags or not);
A useful blog