如何通过事件从UserControl后面的代码中激活JS

在ASP.NET C#中,我想从UserControl的代码隐藏中显示ALERT(’HI’),但不起作用:

用户控制:

     

ASP.NET页面

 protected void btnSubmit_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "s1", "javascript:alert('hi!')", true); } 

更新:

忘了说ASP.NET页面本身是“prettyPhoto”的弹出窗口。

可能有以下可能的原因尝试更改这些并检查它是否有效

  1). ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('hi!')", true);//no need to use javascript with alert when bool set to true 2). ScriptManager.RegisterStartupScript(page, page.GetType(), "msg", "alert('hi!')", true); 3). ClientScript.RegisterClientScriptBlock(GetType(), "sas", "", true);