Kar*_*rdo 1 javascript c# asp.net updatepanel code-behind
在ASP.NET C#中,我想从UserControl的代码隐藏中显示ALERT('HI'),但不起作用:
用户控制:
<asp:UpdatePanel ID="updatepanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click();"/>
</ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)
ASP.NET页面
protected void btnSubmit_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "s1", "javascript:alert('hi!')", true);
}
Run Code Online (Sandbox Code Playgroud)
更新:
忘了说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", "<script> alert('hi!');</script>", true);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3139 次 |
| 最近记录: |