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

📄 default.aspx.cs

📁 一个ASP.NET下的中文内容管理和社区系统
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace ASPNET.StarterKit.Communities.Admin.EditTopics
{
	/// <summary>
	/// Summary description for _Default.
	/// </summary>
	public class _Default : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.CheckBox chkEnableTopicMenu;
		protected System.Web.UI.WebControls.DataGrid dgrdTopics;
		protected System.Web.UI.WebControls.Panel pnlTopics;
		protected System.Web.UI.WebControls.Panel pnlNoTopics;

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.chkEnableTopicMenu.CheckedChanged += new System.EventHandler(this.UpdateEnableTopicMenu);
			this.dgrdTopics.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.Item_Click);
			this.dgrdTopics.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid_ItemDataBound);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion


		//*******************************************************
		//
		// Initialize the Page.
		//
		//*******************************************************
	    
		void Page_Load(Object s, EventArgs e) {
			// display enable topic menu status
			if (!Page.IsPostBack) {
				BindTopics();
				CommunityInfo objCommunityInfo = (CommunityInfo)Context.Items["CommunityInfo"];
				if (objCommunityInfo.EnableTopicMenu)
					chkEnableTopicMenu.Checked = true;
				else
					chkEnableTopicMenu.Checked = false;
			}
		}
	    
		//*******************************************************
		//
		// Bind list of topics to the DataGrid.
		//
		//*******************************************************
		void BindTopics() {
			// Bind the list of Topics
			dgrdTopics.DataSource = TopicUtility.GetAllTopics();
			dgrdTopics.DataKeyField = "ID";
			dgrdTopics.DataBind();
			if (dgrdTopics.Items.Count == 0) {
			pnlNoTopics.Visible = true;
			pnlTopics.Visible = false;
			}
		}

		//*******************************************************
		//
		// User clicked the Delete link.
		//
		//*******************************************************
	    
		void Item_Click(Object s, DataGridCommandEventArgs e) {
			int topicID = (int)dgrdTopics.DataKeys[e.Item.ItemIndex];
			if (e.CommandName=="Delete") {
				AdminUtility.DeleteTopic( topicID );
				BindTopics();
			}
		}
	    
		//*******************************************************
		//
		// Display topic information for each row in the
		// DataGrid.
		//
		//*******************************************************
	    
		private void DataGrid_ItemDataBound(Object s, DataGridItemEventArgs e) {
			// Don't do any binding in header or footer
			if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
				// Get Topic Info from DataItem
				TopicInfo topicInfo = (TopicInfo)e.Item.DataItem;
	    
				// Get Topic from template
				DisplayTopic topic = (DisplayTopic)e.Item.FindControl("Topic");
	    
				// Assign name and image
				topic.Name = topicInfo.Name;
				topic.Image = topicInfo.Image;
	    
				// Add edit url to edit link
				HyperLink lnkEdit = (HyperLink)e.Item.FindControl("lnkEdit");
				lnkEdit.NavigateUrl= String.Format("EditTopic.aspx?id={0}", DataBinder.Eval(e.Item.DataItem, "ID") );    
	    
				// Add confirmation to delete btn
				ImageButton btnDelete = (ImageButton)e.Item.FindControl("btnDelete");
				btnDelete.Attributes.Add("onclick",String.Format("return confirm('Are you sure you want to delete the \"{0}\" topic?')", topicInfo.Name));
			}
		}
	    
	    
	    
		//*******************************************************
		//
		// Updates whether or not topic menu is displayed.
		//
		//*******************************************************
	    
		void UpdateEnableTopicMenu(Object s, EventArgs e) {
			AdminUtility.EnableTopicMenu(chkEnableTopicMenu.Checked);
		}


	}
}

⌨️ 快捷键说明

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