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

📄 authorregisterpanel.ascx.cs

📁 Portal C# Article Live
💻 CS
字号:
namespace Interspire.ArticleLive.Web.Templates.BrightLightStretched.Panels
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	public abstract class AuthorRegisterPanel : BaseUserControl
	{
		protected System.Web.UI.WebControls.TextBox Username;
		protected System.Web.UI.WebControls.TextBox Password;
		protected System.Web.UI.WebControls.TextBox PasswordConfirm;
		protected System.Web.UI.WebControls.TextBox FirstName;
		protected System.Web.UI.WebControls.TextBox LastName;
		protected System.Web.UI.WebControls.TextBox Email;
		protected System.Web.UI.WebControls.TextBox Biography;
		protected System.Web.UI.WebControls.Button SaveButton;
		protected System.Web.UI.WebControls.LinkButton NewLoginButton;
		protected Interspire.ArticleLive.Web.MessageControl MessageControl2;
		protected System.Web.UI.WebControls.Panel FormPanel;
		protected Interspire.ArticleLive.Web.MessageControl Messagecontrol1;
		protected System.Web.UI.WebControls.Panel DonePanel;
		protected Interspire.ArticleLive.Web.ValidationAlerter ValidationAlerter1;
		protected CustomRequiredFieldValidator UsernameReqVal;
		protected CustomRequiredFieldValidator PasswordReqVal;
		protected CustomRequiredFieldValidator BiographyReqVal;
		protected CustomRequiredFieldValidator FirstNameReqVal;
		protected CustomRequiredFieldValidator LastNameReqVal;
		protected CustomRequiredFieldValidator EmailReqVal;
		protected CustomCompareValidator PasswordCompVal;
		protected System.Web.UI.HtmlControls.HtmlInputFile Picture;

		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!Config.Current.EnableAuthorRegistration)
				Visible = false;
			else
			{
				if (!IsPostBack)
				{
					if (Action == "Register")
					{
						Visible = true;
						WindowTitle = ResourceHelper.GetString("BecomeAnAuthor");
						SetDefaultField(Username);
						DataBind();
					}
					else
						Visible = false;
				}
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();

			this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
			this.Load += new System.EventHandler(this.Page_Load);

			base.OnInit(e);
		}
		
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{

		}
		#endregion

		private void SaveButton_Click(object sender, System.EventArgs e)
		{
			if (IsValid)
			{
				UserEngine engine = new UserEngine(Config.Current);

				User author = new User();

				try
				{
					FormToAuthor(author);
					engine.SaveAuthor(author);

					if (Picture.PostedFile.ContentLength > 0)
					{
						author.Picture = FileHelper.UploadAuthorPicture(Picture.PostedFile, author.UserID);
						engine.UpdateUserPicture(author);
					}

					if (Config.Current.AutoApproveAuthors)
						MessageControl.Display(ResourceHelper.GetString("RegisterSuccess"));
					else
						MessageControl.Display(ResourceHelper.GetString("RegisterRequestSuccess"));

					if (Config.Current.AutoApproveAuthors)
					{
						Security.Authentication.LogIn(author.Username, author.Password, false);
						Response.Redirect(Config.Current.ArticlesPagePath + "?a=SubmitArticle");
					}
					else
					{
						FormPanel.Visible = false;
						DonePanel.Visible = true;
					}
				}
				catch(UsernameTakenException)
				{
					MessageControl.DisplayError(ResourceHelper.GetString("UsernameTaken"));
				}
			}
		}
		
		private void FormToAuthor(User author)
		{
			author.FirstName = FirstName.Text;
			author.LastName = LastName.Text;
			author.Email = Email.Text;
			author.Username = Username.Text;
			author.Password = Crypter.EncryptPassword(Password.Text);
			author.Biography = Biography.Text;
		}

		private void ClearForm()
		{
			FirstName.Text = String.Empty;
			LastName.Text = String.Empty;
			Email.Text = String.Empty;
			Username.Text = String.Empty;
			Password.Text = String.Empty;
			Biography.Text = String.Empty;
		}
	}
}

⌨️ 快捷键说明

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