Clientscript.RegisterStartupScript not showing up

本文关键字:up showing not RegisterStartupScript Clientscript | 更新日期: 2023-09-27 18:19:31

我正在开发一个网站,尝试通过ClientScript.RegisterStartUpScript.显示消息

这个成功显示:

ClientScript.RegisterStartupScript(this.GetType(), "myalert", 
  "alert('All questions have been visited !');", true);

尽管它给出了一条带有复选框的消息,上面写着"阻止此页面创建其他对话框"。我没有选中复选框。在我的代码后面,我有这样的条件:

if (lblUnConfirmedQuestions.Text=="0")
{
}
else
{
    ClientScript.RegisterStartupScript(this.GetType(), "msg", 
     "alert( 'Please attempt all the questions !')",true);         
}

这本应该稍后展示,但它没有出现。

在互联网上,我发现了一个从ClientScript消息中删除单引号的建议,我删除了它们,但仍然没有成功。我应该如何显示第二条clientscript消息?

Clientscript.RegisterStartupScript not showing up

"Please attempt all the questions !"只是文本。

您需要这样的东西才能显示警报消息。

ClientScript.RegisterStartupScript(this.GetType(), 
    "msg", "alert('Please attempt all the questions !');",true);