从C#调用javascript函数不起作用 - c#

大家好,我在popupscrit.js文件中使用以下方法:

function afficherMessageInfo( id, message) {


    //Get the A tag
    alert('executing the client code');

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set heigth and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});

    //transition effect     
    $('#mask').fadeIn(500); 
    $('#mask').fadeTo("slow",0.8);  

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center
    $(id).css('top',  winH/2-$(id).height()/2);
    $(id).css('left', winW/2-$(id).width()/2);

    //transition effect
    $(id).fadeIn(1000);




}

$('.window .close').live("click", function (event) {
//Cancel the link behavior
event.preventDefault();
$('#mask').hide();
$('.window').hide();
});

//if mask is clicked
$('#mask').live("click", function (event) {
  $(this).hide();
  $('.window').hide();
});     

我想显示来自c#按钮单击事件的弹出窗口,如下所示:

void BtnEnregistrer_btnClick(object sender, EventArgs e)
    {
        string id = "#info";
        string messageInfo = "le dossier a été crée avec succès";


        string script = String.Format("afficherMessageInfo({0},{1})", id, messageInfo);
        this.Page.ClientScript.RegisterStartupScript(this.GetType(),
        "afficherMessageInfo", script, true);

    }

和html部分:

<script src="../Scripts/jquery.js" type="text/javascript"></script>
<script src="popupScript.js" type="text/javascript"></script>

</head>

<body>
 <form id="form1" runat="server">
<div id="boxes">
<!-- information -->
    <div id="info" class="window" style="display:none;">
        <div class="info_title">
            <div class="pop_title">Information</div>
            <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
        </div>
        <div class="pop_content">
            <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
            <div align="right"><input name="" type="button" value="OK" class="info_bt"/></div>
        </div>
    </div>
<!-- Alerte -->
    <div id="alerte" class="window" style="display:none;">
        <div class="alerte_title">
            <div class="pop_title">Alerte</div>
            <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
        </div>
        <div class="pop_content">
            <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
            <div align="right"><input name="" type="button" value="OK" class="alerte_bt"/></div>
        </div>
    </div>
<!-- validation -->
    <div id="validation" class="window" style="display:none;">
        <div class="validation_title">
            <div class="pop_title">Validation</div>
            <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
        </div>
        <div class="pop_content">
            <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
            <div align="right"><input name="" type="button" value="Annuler" class="validation_bt"/> <input name="" type="button" value="OK" class="validation_bt"/></div>
        </div>
    </div>
<!-- confirmation -->
    <div id="confirmation" class="window" style="display:none;">
        <div class="confirmation_title">
            <div class="pop_title">Demande de Confirmation</div>
            <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
        </div>
        <div class="pop_content">
            <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
            <div align="right"><input name="" type="button" value="Exemple 1" class="confirmation_bt"/> <input name="" type="button" value="Exemple 2" class="confirmation_bt"/> <input name="" type="button" value="Exemple 3" class="confirmation_bt"/> <input name="" type="button" value="Annuler" class="confirmation_bt"/> <input name="" type="button" value="OK" class="confirmation_bt"/></div>
        </div>
    </div>
<!-- Masque pour couvrir la page -->
    <div id="mask"></div>
</div>

警报未显示的pb是多少

参考方案

您传递给javascript函数的参数似乎缺少引号:

线

string script = String.Format("afficherMessageInfo({0},{1})", id, messageInfo); 

应该读

string script = String.Format("afficherMessageInfo('{0}','{1}')", id, messageInfo); 

如何使用PHP从动态输入字段捕获数组值? - javascript

我正在编写一个在线时间跟踪网页,允许用户将学习时间输入该系统。用户将首先输入名称,然后根据日期输入学习时间。一天中可能会有多个学习时间。以下是我第一页的编码,<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"…

Div单击与单选按钮相同吗? - php

有没有一种方法可以使div上的click事件与表单环境中的单选按钮相同?我只希望下面的div提交值,单选按钮很丑代码输出如下:<input id="radio-2011-06-08" value="2011-06-08" type="radio" name="radio_date&#…

在PHP文件中调用javascript函数并在加载HTML文件之后? - javascript

我需要在我的php中调用js函数,但无法正常工作。有人可以告诉我我在做什么错吗?我该如何轻松地做到这一点?谢谢!我有三个文件:  mail.php负责发送$ _POST的内容(工作正常)。我调用我的javascript函数来切换模式,具体取决于邮件是否已发送。 <? ... $response = $sendgrid->send($email);…

将python scikit学习模型导出到pmml - python

我想将python scikit-learn模型导出到PMML。哪个python软件包最合适?我阅读了有关Augustus的内容,但是我无法使用scikit-learn模型找到任何示例。 python大神给出的解决方案 SkLearn2PMML是 JPMML-SkLearn命令行应用程序周围的薄包装。有关受支持的Scikit-Learn Estimator和…

手风琴按年份排序的帖子 - javascript

我有一个自定义类型的推荐信,并且帖子很少。我正在尝试创建一个按年份显示帖子的手风琴。因此,当您单击年份时,它将显示该年份的所有帖子(请参见下面的屏幕截图)。我已经有点用了,问题是当我单击年份时,它仅显示该年的一篇帖子。这是代码-> https://pastebin.com/3F98dcEU <?php get_header();?> <…