【问题标题】:javascript function not firing from gridview rowcommand?javascript函数没有从gridview rowcommand触发?
【发布时间】:2014-03-29 05:42:52
【问题描述】:

我正在尝试从 gridview 行命令后面的代码加载 jQuery 对话框。看起来 javascript 函数没有从后面的代码中触发。

.vb 文件

Private Sub grdLoan_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles grdLoan.RowCommand
  If e.CommandName = "pdf" Then

    Dim message As String = "This is test message"
    ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "ShowPopup('" + message + "');", True)
    'ScriptManager.RegisterClientScriptBlock(grdLoan, Me.[GetType](), "MyScript", "ShowPopup('" + message + "');", True)
   End If
End Sub

如果我在客户端脚本中使用alert,它工作正常。但是 JS 函数不起作用。

 ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "alert("This is test message"", True)

html

<div id="dialog" style="display: none">
</div>
 <script type="text/javascript">
         function ShowPopup(message) {
            alert(message);
                $(function () {
                    $("#dialog").html(message);
                    $("#dialog").dialog({
                        title: "jQuery Dialog Popup",
                        buttons: {
                            Close: function () {
                                $(this).dialog('close');
                            }
                        },
                        modal: true
                    });
                });           
        };
 </script>

【问题讨论】:

    标签: c# jquery asp.net jquery-ui jquery-ui-dialog


    【解决方案1】:

    是的,它不工作,我做了一些修改,现在它在我的最后工作。如果你的页面上有脚本管理器,你可以试试这个:

     string message = "This is test message";
                    string jqueryCodeString = @"<script type='text/javascript'>ShowPopup('" + message + "');</script>";
                    ScriptManager.RegisterStartupScript(this, typeof(string), "Confirm1", jqueryCodeString, false);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多