?? editlink.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 + -