📄 manageblogroll.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.Controls;
namespace CommunityServer.Blogs.Controls
{
/// <summary>
/// Summary description for ManageBlogRoll.
/// </summary>
public class ManageBlogRoll : WeblogAdminTemplatedWebControl
{
public ManageBlogRoll()
{
//
// TODO: Add constructor logic here
//
}
#region Child Controls
Repeater LinkCategoriesList;
Button CreateNewLinkCategory;
#endregion
#region Skin/Control Events/Methods
protected override void OnLoad(EventArgs e)
{
if ( !Page.IsPostBack || !EnableViewState )
{
this.DataBind();
}
base.OnLoad( e );
}
/// <summary>
/// Skin WireUp
/// </summary>
protected override void AttachChildControls()
{
LinkCategoriesList = FindControl( "LinkCategoriesList" ) as Repeater;
if ( LinkCategoriesList != null )
{
LinkCategoriesList.ItemCreated += new RepeaterItemEventHandler(LinkCategoriesList_ItemCreated);
LinkCategoriesList.ItemDataBound += new RepeaterItemEventHandler(LinkCategoriesList_ItemDataBound);
LinkCategoriesList.ItemCommand += new RepeaterCommandEventHandler(LinkCategoriesList_ItemCommand);
}
CreateNewLinkCategory = FindControl( "CreateNewLinkCategory" ) as Button;
if ( CreateNewLinkCategory != null )
{
CreateNewLinkCategory.Click += new EventHandler(CreateNewLinkCategory_Click);
CreateNewLinkCategory.Text = ResourceManager.GetString( "ManageLinks_CreateNewLinkCategory" );
}
ResourceControl label = FindControl( "LinksTitle" ) as ResourceControl;
if(label != null && this.ResourceName !=null)
label.ResourceName = this.ResourceName;
}
public override void DataBind()
{
base.DataBind();
LinkCategoriesList.DataSource = LinkCategories.GetCategories( CurrentWeblog.SectionID, true, false );
LinkCategoriesList.DataBind();
}
private void CleanData()
{
if ( Context != null )
{
Context.Response.Redirect( Context.Request.RawUrl, true );
}
else
{
DataBind();
}
}
#endregion
#region LinkCategoriesList Event Handlers
private void LinkCategoriesList_ItemCreated( Object sender, RepeaterItemEventArgs e )
{
switch ( e.Item.ItemType )
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.SelectedItem:
Repeater LinksList = e.Item.FindControl( "LinksList" ) as Repeater;
if ( LinksList != null )
{
LinksList.DataBinding += new EventHandler(LinksList_DataBinding);
LinksList.ItemDataBound += new RepeaterItemEventHandler(LinksList_ItemDataBound);
LinksList.ItemCommand += new RepeaterCommandEventHandler(LinksList_ItemCommand);
}
Button CreateNewLink = e.Item.FindControl( "CreateNewLink" ) as Button;
if ( CreateNewLink != null )
{
CreateNewLink.Click += new EventHandler(CreateNewLink_Click);
CreateNewLink.Text = ResourceManager.GetString( "ManageLinks_CreateNewLink" );
}
break;
}
}
private void LinkCategoriesList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
switch ( e.Item.ItemType )
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.SelectedItem:
LinkCategory blogLinkCategory = (LinkCategory)e.Item.DataItem;
TextBox LinkCategoryName = e.Item.FindControl( "LinkCategoryName" ) as TextBox;
if ( LinkCategoryName != null )
{
LinkCategoryName.Text = blogLinkCategory.Name;
}
TextBox LinkCategoryDescription = e.Item.FindControl( "LinkCategoryDescription" ) as TextBox;
if ( LinkCategoryDescription != null )
{
LinkCategoryDescription.Text = blogLinkCategory.Description;
}
CheckBox LinkCategoryIsEnabled = e.Item.FindControl( "LinkCategoryIsEnabled" ) as CheckBox;
if ( LinkCategoryIsEnabled != null )
{
LinkCategoryIsEnabled.Checked = blogLinkCategory.IsEnabled;
}
Button saveLinkCategory = e.Item.FindControl( "SaveLinkCategory" ) as Button;
if ( saveLinkCategory != null )
{
saveLinkCategory.Text = ResourceManager.GetString( "Save" );
saveLinkCategory.CommandName = "SaveLinkCategory";
saveLinkCategory.CommandArgument = blogLinkCategory.LinkCategoryID.ToString();
}
Button deleteLinkCategory = e.Item.FindControl( "DeleteLinkCategory" ) as Button;
if ( deleteLinkCategory != null )
{
deleteLinkCategory.Text = ResourceManager.GetString( "Delete" );
deleteLinkCategory.CommandName = "DeleteLinkCategory";
deleteLinkCategory.Attributes.Add("onclick",string.Format("return confirm('{0}');",ResourceManager.GetString("ManageLinks_ConfirmDeleteCategory")));
deleteLinkCategory.CommandArgument = blogLinkCategory.LinkCategoryID.ToString();
}
ThemedImageButton moveUp = e.Item.FindControl( "MoveCategoryUp" ) as ThemedImageButton;
if ( moveUp != null )
{
moveUp.CommandName = "MoveUp";
moveUp.CommandArgument = blogLinkCategory.LinkCategoryID.ToString();
}
ThemedImageButton moveDown = e.Item.FindControl( "MoveCategoryDown" ) as ThemedImageButton;
if ( moveDown != null )
{
moveDown.CommandName = "MoveDown";
moveDown.CommandArgument = blogLinkCategory.LinkCategoryID.ToString();
}
Button CreateNewLink = e.Item.FindControl( "CreateNewLink" ) as Button;
if ( CreateNewLink != null )
{
CreateNewLink.CommandArgument = blogLinkCategory.LinkCategoryID.ToString();
}
break;
}
}
#endregion
#region LinksList Event Handlers
private void LinksList_DataBinding(object sender, EventArgs e)
{
Repeater LinksList = (Repeater)sender;
RepeaterItem container = (RepeaterItem)LinksList.NamingContainer;
LinkCategory category = (LinkCategory)container.DataItem;
LinksList.DataSource = Links.GetLinks( category.LinkCategoryID, true, false );
}
private void LinksList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
switch ( e.Item.ItemType )
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.SelectedItem:
Link blogLink = (Link)e.Item.DataItem;
String commandArg = blogLink.LinkID.ToString() + ":" + blogLink.LinkCategoryID.ToString();
TextBox LinkTitle = e.Item.FindControl( "LinkTitle" ) as TextBox;
if ( LinkTitle != null )
{
LinkTitle.Text = blogLink.Title;
}
TextBox LinkUrl = e.Item.FindControl( "LinkUrl" ) as TextBox;
if ( LinkUrl != null )
{
LinkUrl.Text = blogLink.Url;
}
CheckBox LinkIsEnabled = e.Item.FindControl( "LinkIsEnabled" ) as CheckBox;
if ( LinkIsEnabled != null )
{
LinkIsEnabled.Checked = blogLink.IsEnabled;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -