我有一个将在远程IIS服务器上运行的应用程序。我正在完成对警报的一些更改(从MsgBox更改为Response.Write)。问题是,我用于另一页警报的这一行工作正常:
Response.Write("<script type='text/javascript'>alert('Applicant has been added under the Credential Tab');</script>")
但是,当我在我现在正在使用的页面上尝试完全相同的行时,不会弹出警报,但是后端代码可以正常运行且没有错误。这是我尝试过Response.Write的代码,但没有像其他页面那样显示窗口:
' Open the connection.
conn.Open()
' Execute the command.
'Response.Write("<script type='text/javascript'>alert('Applicant has been added under the Employement tab');</script>")
cmd.ExecuteNonQuery()
cmd2.ExecuteNonQuery()
'End If
Response.Write("<script type='text/javascript'>alert('Applicant has been added under the Employement tab');</script>")
'MsgBox("Applicant has been added under the Employment tab.")
End If
我不太确定自己错过了什么,但是我只是按照我在上一页中编写代码行的方式进行操作。
编辑:
下面是有效的代码:
If cmbOfferLetterStatus.Text.Equals("Accepted") Then
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("DBConn").ToString())
Dim cmd As New SqlCommand()
cmd.Connection = conn
cmd.CommandText = "UPDATE tblTEST SET Status = 3 WHERE AppID=@AppID"
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@AppID", xSelectedPersonID)
conn.Open()
cmd.ExecuteNonQuery()
Response.Write("<script type='text/javascript'>alert('Applicant has been added under the Credential Tab');</script>")
End If
这是我用于上面代码块的脚本:
<script type = "text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("You are about to delete this applicant record from the table. Do you want to proceed?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>