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

📄 editlink.cs

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

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


    //*********************************************************************
    //
    // EditLink Class
    //
    // Represents the Edit Link page. Enables users to edit existing links.
    //
    //*********************************************************************

    public class EditLink : ContentEditPage {
    
        string _skinFileName = "Links_AddLink.ascx";
        string _sectionContent = "ASPNET.StarterKit.Communities.Links.LinksSection";
        
 
		TextBox txtUrl;
		TextBox txtTitle;
		TextBox txtDescription;
		TopicPicker dropTopics;
		
		LinkTitle previewLinkTitle;
		BriefDescription previewDescription;
        DisplayTopic previewTopic;



        //*********************************************************************
        //
        // ContentPageID Property
        //
        // Stores the ID of the content being edited in View State
        //
        //*********************************************************************

        int ContentPageID {
            get {
                return (int)ViewState["ContentPageID"];
            }
            set { ViewState["ContentPageID"] = value; }
        }



        //*********************************************************************
        //
        // SkinLoadLink
        //
        // The skin load event happens after a page skin has been loaded.
        // Here, we grab the necessary controls from the page skin.
        //
        //*********************************************************************
        void SkinLoadLink(Object s, SkinLoadEventArgs e) {

			txtTitle = (TextBox)GetControl(e.Skin,"txtTitle");
			txtUrl = (TextBox)GetControl(e.Skin,"txtUrl");
			txtDescription = (TextBox)GetControl(e.Skin,"txtDescription");
            dropTopics = (TopicPicker)GetControl(e.Skin, "dropTopics");

            previewLinkTitle = (LinkTitle)GetControl(e.Skin, "previewLinkTitle");
            previewDescription = (BriefDescription)GetControl(e.Skin, "previewDescription");
            previewTopic = (DisplayTopic)GetControl(e.Skin, "previewTopic" );
        }
        


        //*********************************************************************
        //
        // OnLoad Method
        //
        // Assigns values to the controls from the page skin.
        //
        //*********************************************************************
		protected override void OnLoad(EventArgs e) {
	  
		  if (!Page.IsPostBack) {
              ContentPageID = Int32.Parse(Context.Request.QueryString["id"]);
		  
              EnsureChildControls();

		      LinkInfo _linkInfo = (LinkInfo)LinksUtility.GetLink(objUserInfo.Username, ContentPageID);
			  txtTitle.Text = _linkInfo.Title;
		      txtDescription.Text = _linkInfo.BriefDescription;
			  txtUrl.Text = _linkInfo.Url;
		  }
		}



        //*********************************************************************
        //
        // PreviewLink Method
        //
        // When previewing a link, we want to transfer everything from 
        // the text boxes to the labels.
        //
        //*********************************************************************
        void PreviewLink(Object s, EventArgs e) {
            previewLinkTitle.Text = txtTitle.Text;
            previewLinkTitle.Url = txtUrl.Text;
            previewDescription.Text = txtDescription.Text;
            if (objSectionInfo.EnableTopics)
                previewTopic.Name = dropTopics.SelectedItem.Text;
        }



        //*********************************************************************
        //
        // SubmitLink Method
        //
        // This method is raised by clicking the Add button in the Add 
        // Article form. It adds the article to the database.
        //
        //*********************************************************************

        void SubmitLink(Object s, EventArgs e) {
			if (Page.IsValid) {
			             
			 // Get Topic
			 int topicID = -1;
			 if (objSectionInfo.EnableTopics)
			     topicID = Int32.Parse(dropTopics.SelectedItem.Value);    

			 // Update
			 LinksUtility.EditLink
			 (
				objUserInfo.Username,
                objSectionInfo.ID,
				ContentPageID,
				txtTitle.Text,
				txtUrl.Text,
				txtDescription.Text,
				topicID
			  );

			 Context.Response.Redirect(CommunityGlobals.CalculatePath("Default.aspx"));
			}
        }


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

        public EditLink() : base() {
            // Assign a default skin file name
            SkinFileName = _skinFileName;
            
            // Specify Section Content
            SectionContent = _sectionContent;
            
            // Wire-up event handlers
            this.SkinLoad += new SkinLoadEventHandler(SkinLoadLink);
            this.Preview += new PreviewEventHandler(PreviewLink);
            this.Submit += new SubmitEventHandler(SubmitLink);
        }





    }
}

⌨️ 快捷键说明

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