How to fire JS from code behind of a UserControl by an event

前端 未结 1 1573
北恋
北恋 2021-01-23 14:13

In ASP.NET C#, I want to show an ALERT(\'HI\') from codebehind of a UserControl but doesn\'t work:

User Control:



        
相关标签:
1条回答
  • 2021-01-23 14:44

    there may be below possible reasons try to change these and check it works or not

     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);
    
    0 讨论(0)
提交回复
热议问题