我有一个登录页面。 单击登录按钮后,将执行回发操作,并在从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>