I am trying to use ScriptManager.RegisterStartupScript but I am not sure where to place it. For example: on a page load, or inside a DeleteButtonClick even handler method. On my page there's a delete asp.button. And I want to call my JavaScript function every time when a user clicks on the delete button. Thanks
Register the script during the PreRender phase:
protected void Page_PreRender(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, GetType(), "Key",
"alert('call in pre-render');", true);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.