我正在尝试从gridview rowcommand后面的代码加载jQuery对话框。看起来javascript函数没有从后面的代码中解雇。
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)
<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>
答案 0 :(得分:1)
是的,它没有用,我做了一些修改,现在它在我的工作。如果您的页面上有脚本管理器,您可以尝试:
string message = "This is test message";
string jqueryCodeString = @"<script type='text/javascript'>ShowPopup('" + message + "');</script>";
ScriptManager.RegisterStartupScript(this, typeof(string), "Confirm1", jqueryCodeString, false);