0
這是我sciprt,它顯示一個消息框帶有「確定」和「取消」按鈕如何立即調用javascript函數從VB代碼
<script type="text/javascript"> function Confirm() {
var confirm_value = document.createElement('INPUT');
confirm_value.type = 'hidden';
confirm_value.name = 'confirm_value';
if (confirm('Continue?')) {
confirm_value.value = 'Yes';
} else {
confirm_value.value = 'No';}
document.forms[0].appendChild(confirm_value);} </script>
在我的節目我跑一查詢,如果沒有結果的話,我這顯示「對話框」複選框
我要調用的函數獲得查詢結果,但我當前的代碼後,似乎一切,而不是立即之後要運行它。
If reader.read = false then
If Not Page.ClientScript.IsStartupScriptRegistered(Me.GetType(), "alertscript") Then
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alertscript", "Confirm();", True)
End if
Dim confirmValue As String = Request.Form("confirm_value")
If confirmValue = "Yes" Then
'Do stuff here
End if
End if
這似乎是在Web窗體和VB.NET中的世界共同的根本誤解。 –