⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.cs

📁 ASP.NET简洁论坛源代码 这是一个简单的论坛
💻 CS
字号:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.Security;
using NetFocus.Web.Core;

namespace NetFocus.Web.Applications.Forum
{
    [ParseChildren(true)]
    public class Login : UserControl
    {
        protected TextBox userName;
        protected TextBox password;
        protected IButton loginButton;
        private WebContext context = WebContext.Current;

        protected override void OnInit(EventArgs e)
        {
            this.EnableViewState = true;
            base.OnInit(e);
        }
        protected override void OnLoad(EventArgs e)
        {
            if (loginButton != null)
            {
               loginButton.Click += new EventHandler(LoginButton_Click);
            }
        }

        private void RegisterButton_Click(Object sender, EventArgs e)
        {
            Context.Response.Redirect(SiteUrls.Instance().Register, true);
        }
        private void LoginButton_Click(Object sender, EventArgs e)
        {
            if (Users.ValidateUser(userName.Text, password.Text))
            {
                ForumUser user = ForumUsers.GetUser(userName.Text);
                if (user.UserStatus == (int)UserStatus.Locked)
                {
                    Globals.ShowMessage(Page, "LockedUser", "您的帐号已经被冻结,请联系系统管理员。");
                }
                else
                {
                    context.User = user;
                    UserCookie.SaveCookie(FormsAuthentication.GetAuthCookie(userName.Text, false), 30);
                    Context.Response.Redirect(SiteUrls.Instance().Home, true);
                }
            }
            else
            {
                Globals.ShowMessage(Page, "InValidUser", "用户名或密码无效。");
            }

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -