![](/img/trans.png)
[英]How To Fire An Event /Function From A Code Behind When I Type 6Th Digit In A Textbox?
[英]How to fire JS from code behind of a UserControl by an event
在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>
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", "<script> alert('hi!');</script>", true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.