I have a user control with a public method:
public void ShowDetails(Guid requestGuid)
{
Label1.Text = reportGuid.ToString(); //only for testing
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "ShowEmailPreview", "alert('hi');", true);
//ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowEmailPreview", "alert('hi');", true); //doesn't work
//Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowEmailPreview", "alert('hi');", true); //doesn't work
}
When hosting page for this user control calls ShowDetails(), I need to call some javascript.
I tried with ScriptManager.RegisterStartupScript and Page.ClientScript.RegisterStartupScript but it doesn't work... However if I add an UpdatePanel on my control and add script for UpdatePanel as shown above, it works well.
I don't want to add UpdatePanel onto my control just for the sake of calling javascript.
Am I missing something?
Thank you!