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

📄 edituserprofile.cs

📁 微软的.NET论坛的源代码(COOL!!!)
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using AspNetForums;
using AspNetForums.Components;
using System.ComponentModel;
using System.IO;

namespace AspNetForums.Controls {


    public class EditUserProfile : SkinnedForumWebControl {

        string skinFilename = "Skin-EditUserInfo.ascx";
        bool requirePasswordForUpdate =  false;

        // *********************************************************************
        //  EditUserInfo
        //
        /// <summary>
        /// Constructor
        /// </summary>
        /// 
        // ********************************************************************/
        public EditUserProfile() {

            // Set the default skin
            if (SkinFilename == null)
                SkinFilename = skinFilename;

        }
	
        
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// This method populates the user control used to edit a user's information
        /// </summary>
        /// <param name="control">Instance of the user control to populate</param>
        /// 
        // ***********************************************************************/
        override protected void InitializeSkin(Control skin) {

            Label label;
            TextBox textbox;
            DropDownList dropdownlist;
            CheckBox checkbox;
            Button submit;
            System.Web.UI.WebControls.Image image;

            // Set the name
            label = (Label) skin.FindControl("Username");
            label.Text = ForumUser.Username;

            // Set the email address
            textbox = (TextBox) skin.FindControl("Email");
            textbox.Text = ForumUser.Email;

            // Set the time zone
            dropdownlist = (DropDownList) skin.FindControl("Timezone");
            dropdownlist.Items.FindByValue(ForumUser.Timezone.ToString()).Selected = true;

            // Set the date format
            dropdownlist = (DropDownList) skin.FindControl("DateFormat");
            try {
                dropdownlist.Items.FindByValue(ForumUser.DateFormat).Selected = true;
            } catch (Exception ex) {
                ; // unknown date format, don't set
            }

            // Email tracking option
            checkbox = (CheckBox) skin.FindControl("EmailTracking");
            if (checkbox != null)
                checkbox.Checked = ForumUser.TrackPosts;

            // Hide read threads
            checkbox = (CheckBox) skin.FindControl("UnreadThreadsOnly");
            checkbox.Checked = ForumUser.HideReadThreads;

            // Occupation
            textbox = (TextBox) skin.FindControl("Occupation");
            if (textbox != null)
                textbox.Text = ForumUser.Occupation;

            // Location
            textbox = (TextBox) skin.FindControl("Location");
            if (textbox != null)
                textbox.Text = ForumUser.Location;

            // Interests
            textbox = (TextBox) skin.FindControl("Interests");
            if (textbox != null)
                textbox.Text = ForumUser.Interests;

            // MsnIm
            textbox = (TextBox) skin.FindControl("MsnIm");
            if (textbox != null)
                textbox.Text = ForumUser.MsnIM;

            // YahooIm
            textbox = (TextBox) skin.FindControl("YahooIm");
            if (textbox != null)
                textbox.Text = ForumUser.YahooIM;

            // AolIm
            textbox = (TextBox) skin.FindControl("AolIm");
            if (textbox != null)
                textbox.Text = ForumUser.AolIM;

            // ICQ
            textbox = (TextBox) skin.FindControl("ICQ");
            if (textbox != null)
                textbox.Text = ForumUser.IcqIM;

            // FakeEmail
            textbox = (TextBox) skin.FindControl("FakeEmail");
            textbox.Text = ForumUser.PublicEmail;

            // WebSite
            textbox = (TextBox) skin.FindControl("Website");
            if (textbox != null)
                textbox.Text = ForumUser.Url;

            // Signature
            textbox = (TextBox) skin.FindControl("Signature");
            if (textbox != null)
                textbox.Text = ForumUser.Signature;

            // Style
            dropdownlist = (DropDownList) skin.FindControl("SiteStyle");
            if (dropdownlist != null) {
                foreach (String styleOption in Globals.SiteStyles) {
                    dropdownlist.Items.Add(styleOption);
                }
            }


            // Attempt to apply the user's style ... but it might not exist
            try {
                dropdownlist.Items.FindByText(ForumUser.SiteStyle).Selected = true;
            } catch (Exception exception) {
                ; // Type not found
            }

            // Post view order
            dropdownlist = (DropDownList) skin.FindControl("PostViewOrder");
            dropdownlist.Items.Add(new ListItem("Oldest first", "0"));
            dropdownlist.Items.Add(new ListItem("Newest first", "1"));
            dropdownlist.Items.FindByValue(Convert.ToInt32(ForumUser.ShowPostsAscending).ToString()).Selected = true;

            // Has Icon
            Control hasIcon = skin.FindControl("HasIcon");

            if ((ForumUser.HasIcon) && (hasIcon != null)) {
                image = (System.Web.UI.WebControls.Image) skin.FindControl("CurrentIcon");
                image.ImageUrl = ForumUser.ImageUrl;
                hasIcon.Visible = true;

                ((CheckBox) skin.FindControl("ShowIcon")).Checked = ForumUser.ShowIcon;
            }

/*
            // Are we in administration mode?
            if (Mode == UserInfoEditMode.Admin) {
                ((Control) skin.FindControl("Administration")).Visible = true;

                // Is the user's profile approved?
                checkbox = (CheckBox) skin.FindControl("ProfileApproved");
                checkbox.Checked = ForumUser.IsProfileApproved;

                // Is the user banned
                checkbox = (CheckBox) skin.FindControl("Banned");
                checkbox.Checked = !ForumUser.IsApproved;

                // Is the user trusted
                checkbox = (CheckBox) skin.FindControl("Trusted");
                checkbox.Checked = ForumUser.IsTrusted;



            }
*/

            // Do we require a password for doing an update?
            if (!RequirePasswordForUpdate) {
                // Don't ask for a password when we update
                ((Control) skin.FindControl("PasswordRequired")).Visible = false;

                // Disable the validator
                ((RequiredFieldValidator) skin.FindControl("ValidatePassword")).Enabled = false;
            }

            // Wire-up the button

⌨️ 快捷键说明

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