简体   繁体   中英

Logout issues with validators on the page. ASP.NET C#

I have a website that I log into. In my pages that are viewable while logged in, there is a logout button that logs the user out and takes the user back to the login page. The problem is on certain pages, I have textboxes that have requiredFieldValidators. Now when I hit the logout button, the requiredFieldValidators for the textboxes pop up and won't let me log out.

What do I need to change?

protected void btLogout_Click(object sender, EventArgs e)
{
    Session.Abandon();
    Session.Contents.RemoveAll();
    System.Web.Security.FormsAuthentication.SignOut();
    Response.Redirect("~/Default.aspx");
}

在注销按钮声明中使用以下内容:

CausesValidation="false"

阅读有关验证组的信息

您需要为要ValidationGroup的验证器和控件设置ValidationGroup属性,并确保“注销”按钮不属于该组。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM