Clientscript.RegisterStartupScript没有显示

时间:2014-08-26 13:53:30

标签: c# asp.net

我正在开发一个网站,我试图通过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消息中删除单引号的建议,我删除了它们但仍然无法成功。我应该怎样做才能显示第二条客户邮件消息?

1 个答案:

答案 0 :(得分:1)

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

您需要这样的内容才能显示警告信息。

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