服务器的挂起执行,显示确认框,根据确认框的响应恢复其余代码

时间:2018-07-14 06:06:54

标签: .net

我有一个登录页面。 单击登录按钮后,将执行回发操作,并在从DB(SQL Server)中获取结果后进行身份验证。 如果停用标记为true,则代码执行应停止,并且需要向用户(客户端)显示一个确认框,其余代码应根据来自“确认”框的响应恢复执行。 请帮忙。

C#代码为:

    if (dt.Rows[0]["IsDeleted"].ToString() == "True")
    {
      Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "Confirm()", true);
                        string confirmValue = Request.Form["confirm_value"];    
                        if (confirmValue == "Yes")
                        {
                            string RegisterQuery = "UPDATE [User] SET IsDeleted=0 where Id = '" + Session["UserId"].ToString() + "'";
                            dbClass.ConnectDataBaseToInsert(RegisterQuery);
                            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Your Account has been Reactivated Succesfully!!')", true);
                            boolReturnValue = true;
                        }
                        else
{
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Your Account remains Deactivated!!')", true);
                        return false;
                    }

JavaScript是:

<script type="text/javascript">
        function Confirm() {
            var confirm_value = document.createElement("INPUT");
            confirm_value.type = "hidden";
            confirm_value.name = "confirm_value";
            if (confirm("Your Account is deactivated. Do you want to Reactivate your account and continue?")) {
                confirm_value.value = "Yes";
            } else {
                confirm_value.value = "No";
            }
            document.forms[0].appendChild(confirm_value);
        }
    </script>

0 个答案:

没有答案