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

📄 passwordreminder.cs

📁 一个ASP.NET下的中文内容管理和社区系统
💻 CS
字号:
namespace ASPNET.StarterKit.Communities {

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using ASPNET.StarterKit.Communities;
    using System.Web.Security;


    //*********************************************************************
    //
    // PasswordReminder Class
    //
    // Represents the Password Reminder page which enables users to
    // receive an email password reminder.
    //
    //*********************************************************************

    public class PasswordReminder : SkinnedCommunityControl {
    
        string _skinFileName = "Users_PasswordReminder.ascx";

        TextBox txtEmail;
        Button btnSend;
        Button btnCancel;
        Panel pnlForm;
        Panel pnlInvalidEmail;
        Panel pnlSent;


        //*********************************************************************
        //
        // PasswordReminder Constructor
        //
        // Calls the base SkinnedCommunityControl constructor
        // and assigns the default page skin. 
        //
        //*********************************************************************

		public PasswordReminder() : base() {
            // Assign a default skin file name
            if (SkinFileName == null)
                SkinFileName = _skinFileName;
        }

        
        //*********************************************************************
        //
        // SkinType Property
        //
        // Specifies the skins directory where this page's skin file is located.
        //
        //*********************************************************************
        
        override protected string SkinType {
            get { return "ContentSkins"; }
        }


        //*********************************************************************
        //
        // InitializeSkin Method
        //
        // Retrieves all the controls from the Page Skin
        //
        //*********************************************************************

        override protected void InitializeSkin(Control skin) {
            // Find the Email TextBox
            txtEmail = (TextBox)GetControl(skin, "txtEmail");

            // Find the Form Panel
            pnlForm = (Panel)GetControl(skin, "pnlForm");

            
            // Find the Invalid Email Panel
            pnlInvalidEmail = (Panel)GetControl(skin, "pnlInvalidEmail");
            pnlInvalidEmail.Visible = false;
                      
            // Find the Sent Panel
            pnlSent = (Panel)GetControl(skin, "pnlSent");
            pnlSent.Visible = false;          
                      
                        
            // Find Send Button
            btnSend = (Button)GetControl(skin, "btnSend");
    		btnSend.Click += new System.EventHandler(btnSend_Click);

            // Find Cancel Button
            btnCancel = (Button)GetControl(skin, "btnCancel");
            btnCancel.CausesValidation = false;
    		btnCancel.Click += new System.EventHandler(btnCancel_Click);
        } 
        

        //*********************************************************************
        //
        // btnSend_Click Method
        //
        // Sends the password reminder and displays the Sent panel.
        //
        //*********************************************************************
        
        void btnSend_Click(Object s, EventArgs e) {
            if (Page.IsValid) {
                // Get User Profile
                ProfileInfo _profileInfo = UserUtility.GetProfileFromEmail(txtEmail.Text);
                if (_profileInfo == null) {
                    pnlInvalidEmail.Visible = true;
                    return;
                }
                else
                    pnlInvalidEmail.Visible = false;

                // Get the reminder message
                MessageInfo reminderEmail = MessageUtility.GetMessage("Password Reminder");
                
          
                
                // Send formatted email
                EmailUtility.SendFormattedEmail
                (
                    String.Format("reminder@{0}", CommunityGlobals.PrimaryDomain),
                    reminderEmail,
                    _profileInfo,
                    CommunityGlobals.SmtpServer
                );
            }
            pnlForm.Visible = false;
            pnlSent.Visible = true;
        }      
        

        //*********************************************************************
        //
        // btnCancel_Click Method
        //
        // Cancels the password reminder and redirects the user back
        // to the Default page.
        //
        //*********************************************************************
        
        void btnCancel_Click(Object s, EventArgs e) {
            Context.Response.Redirect("~/Default.aspx");
        } 
 
 
        


    }
}

⌨️ 快捷键说明

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