没有按钮Onclick动作后的代码中的JavaScript弹出窗口

时间:2019-02-16 04:05:27

标签: javascript asp.net vb.net

我已经阅读了许多线程,无法弄清楚这一点,因为它们都与单击按钮来调用JavaScript有关。我有一个简单的javascript弹出窗口,我想在asp.net项目中的vb代码期间调用它。每次调用javascript时,程序都会继续运行,并且不会计算弹出窗口中的变量。

我需要程序停止,等待弹出的回复,然后根据回复继续。我想念什么?前一个可以很好地运行,因为它是基于按钮OnClientClick方法的条件,但是后两个在后面的代码中。我需要程序停止,等待响应,然后根据响应继续。不会发生这种情况,请使用ScriptManager.RegisterStartupScript或其他javascript调用,因为它们不会停止程序等待响应。后两个没有按钮单击事件来触发它们,只有一个编程代码调用。

HTML代码:

        <script type="text/javascript">
            function Payment() {
                var payment_value = document.createElement("INPUT");
                payment_value.type = "hidden";
                payment_value.name = "payment_value";
                if (confirm("Are you sure you want To Cancel this Payment?")) {
                    payment_value.value = "Yes";
                } else {
                    payment_value.value = "No";
                }
                document.forms[0].appendChild(payment_value);
            }
        </script>
        <script type="text/javascript">
            function LateFee() {
                var latefee_value = document.createElement("INPUT");
                latefee_value.type = "hidden";
                latefee_value.name = "latefee_value";
                if (confirm("This payment is over 30 days, do you want to add a Late Fee ($99.00) to this incident?")) {
                    latefee_value.value = "Yes";
                } else {
                    latefee_value.value = "No";
                }
                document.forms[0].appendChild(latefee_value);
                console.log(latefee_value)
            }
        </script>
        <script type="text/javascript">
            function LateFeePrint() {
                var latefeeprint_value = document.createElement("INPUT");
                latefeeprint_value.type = "hidden";
                latefeeprint_value.name = "latefeeprint_value";
                if (confirm("Late Fee Updated Successfully, do you want to print a Late Fee Notice?")) {
                    latefeeprint_value.value = "Yes";
                } else {
                    latefeeprint_value.value = "No";
                }
                document.forms[0].appendChild(latefeeprint_value);
            }
        </script>

<h2><%: Title %></h2>
<p class="text-danger">
    <asp:Literal runat="server" ID="Literal1" />
</p>

VB,净代码:

    If NumDays > 30 And TempLateFee <> "$99.00" Then
        Dim LateFeeValue As String = Request.Form("latefee_value")
        'Call Javascript and popup the modal
        ScriptManager.RegisterStartupScript(Me, Page.GetType, "LateFeeCall", "LateFee()", True)
        'use the result to calculate the late fee
        If LateFeeValue = "No" Then
        ElseIf LateFeeValue = "Yes" Then
            AccountBalance = 0
            Call UpdateLateFee()
            Call GetAlarmInfo()
            Call LoadAlarmInfo()
            Call LoadBalanceInfo()
        End If
    End If

0 个答案:

没有答案