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

📄 showtopic.aspx.cs

📁 如果要连接的数据库文件和当前文件在同一个目录下
💻 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 X2Blog
{
	/// <summary>
	/// showTopic 的摘要说明。
	/// </summary>
	public class showTopic : MyPage
	{
		protected System.Web.UI.WebControls.Literal lTitle;
		protected System.Web.UI.WebControls.Literal lHeadTitle;
		protected System.Web.UI.WebControls.Literal lHits;
		protected System.Web.UI.WebControls.Literal lAuthor;
		protected System.Web.UI.WebControls.Literal lTime;
		protected System.Web.UI.WebControls.Literal lSort;
		protected System.Web.UI.WebControls.Literal lMemo;
		protected System.Web.UI.WebControls.Literal lStyle;
		protected System.Web.UI.WebControls.Repeater rptInfo;
		protected System.Web.UI.HtmlControls.HtmlInputHidden hidTopicId;
		protected System.Web.UI.WebControls.PlaceHolder phPostComment;
		protected System.Web.UI.WebControls.Literal lLanguage;
	
		private void Page_Load(object sender, System.EventArgs e)
		{	
			hidTopicId.Value=q("id");
			this.ConnectDb();
			doh.Reset();
			doh.SqlCmd="select info.title,info.author,info.date,info.abstract,info.content,infoSort.sortName from info,infoSort,users where infoSort.id=info.sortId and info.id=@id";
			//doh.SqlCmd="select * from info where id=1137";
			doh.AddSqlCmdParameters("@id",q("id"));
			DataTable myDt=doh.GetDataTable();
			
			if(myDt.Rows.Count!=0)
			{

				//				doh.Reset();
				//				doh.ConditionExpress="id=@id";
				//				doh.AddConditionParameter("@id",q("id"));
				//				doh.Count("info","hits");
			
				lStyle.Text="<link rel=\"stylesheet\" href=\"../skin/"+this.GetValueByKey("style")+"/showTopic.css\" type=\"text/css\" />";
				lHeadTitle.Text=lTitle.Text=myDt.Rows[0]["title"].ToString();
				lAuthor.Text=myDt.Rows[0]["author"].ToString();
				lTime.Text=myDt.Rows[0]["date"].ToString();
				lSort.Text=myDt.Rows[0]["sortName"].ToString();

				if(myDt.Rows[0]["content"].ToString().Length>0)
				{
					lMemo.Text="【摘要】<br/>";
					lMemo.Text+=myDt.Rows[0]["abstract"].ToString();
					lMemo.Text+="<br/>";
					lMemo.Text+="【全文】<br/>";
					lMemo.Text+=myDt.Rows[0]["content"].ToString();
				}
				else
				{
					lMemo.Text=myDt.Rows[0]["abstract"].ToString();
				}
			}

			doh.Reset();
			doh.ConditionExpress="info.sortId=infoSort.id and info.id=@id";
			doh.AddConditionParameter("@id",q("id"));
			//detect if this topic allows comment
			if(Convert.ToInt32(doh.GetValue("info,infoSort","infoSort.allowComment"))==1)
			{
				doh.Reset();
				phPostComment.Visible=true;
				doh.SqlCmd="select * from comment where parentId=@parentId order by date";
				doh.AddSqlCmdParameters("@parentId",q("id"));
				rptInfo.DataSource=doh.GetDataSet();
				rptInfo.DataBind();
			}

			lLanguage.Text="<script type=\"text/javascript\" src=\"../js/lang/"+language+".js\"></script>";
		}
		private int i=0;
		public void rptInfo_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
		{
			if(e.Item.ItemType.ToString()=="Item" || e.Item.ItemType.ToString()=="AlternatingItem")
			{
				string url=DataBinder.Eval(e.Item.DataItem,"author","");

				i++;
				Literal _lReplyTime=(Literal)e.Item.FindControl("lReplyTime");
				Literal _lReplyMemo=(Literal)e.Item.FindControl("lReplyMemo");
				_lReplyTime.Text="<span>【评论"+i.ToString()+"】</span><span>时间:"+DataBinder.Eval(e.Item.DataItem,"date","")+"</span><span>作者:"+url+"</span>";
				_lReplyMemo.Text=DataBinder.Eval(e.Item.DataItem,"content","");
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

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