Ejemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // 在此处放置用户代码以初始化页面
            if (IsSafe(Request.QueryString["id"], 2) == false)
            {
                Response.Write("非法参数,<a href=BlogIndex.aspx>点此返回</a>");
                Response.End();
            }
            string ST_dns = ConfigurationSettings.AppSettings["conStr"];
            string ST_sql = "select * from ST_news where ST_n_id=" + Request.QueryString["id"] + "";
            //最新推荐文章
            string ST_cmd_sql = "select top 10 * from ST_news where ST_n_iscmd=1 order by ST_n_id desc";

            ST_myConn = new SqlConnection(ST_dns);
            SqlDataAdapter ST_myCmd    = new SqlDataAdapter(ST_sql, ST_myConn);
            SqlDataAdapter ST_classCmd = new SqlDataAdapter("select ST_c_id,ST_c_name from ST_class", ST_myConn);
            SqlDataAdapter ST_cmdCmd   = new SqlDataAdapter(ST_cmd_sql, ST_myConn);

            DataSet ST_ds = new DataSet();

            ST_myCmd.Fill(ST_ds, "新闻查看");

            DataSet ST_classds = new DataSet();

            ST_classCmd.Fill(ST_classds, "类别列表");

            DataSet ST_cmdds = new DataSet();

            ST_cmdCmd.Fill(ST_cmdds, "推荐文章");

            NewsShow.DataSource = ST_ds.Tables[0];
            NewsShow.DataBind();

            ClassList.DataSource = new DataView(ST_classds.Tables[0]);
            ClassList.DataBind();

            CmdList.DataSource = new DataView(ST_cmdds.Tables[0]);
            CmdList.DataBind();
            //调用ST_UpdateHit()方法
            ST_UpdateHit();
            if (Request.Cookies["colors"] != null)
            {
                string   ST_test      = Request.Cookies["colors"].Value;
                String[] ST_colorList = ST_test.Split(new char[] { ',' });
                ST_bgcolor = ST_colorList[0];
                ST_tcolor  = ST_colorList[1];
            }
            else
            {
                ST_bgcolor = "#FFDE94";
                ST_tcolor  = "#efe3ce";
            }
            Page.DataBind();
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string ST_sql = "select * from ST_news where ST_n_id=" + Request.QueryString["id"] + "";
         conn.Open();
         SqlDataAdapter da = new SqlDataAdapter(ST_sql, conn);
         DataSet        ds = new DataSet();
         da.Fill(ds);
         NewsShow.DataSource = ds.Tables[0];
         NewsShow.DataBind();
         ST_UpdateHit();
     }
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 在此处放置用户代码以初始化页面
            if (IsSafe(Request.QueryString["id"], 2) == false)
            {
                Response.Write("错误页面,<a href=BlogIndex.aspx>点此返回</a>");
                Response.End();
            }
            string ST_sql = "select * from ST_news where ST_n_id=" + Request.QueryString["id"] + "";
            //最新推荐文章
            string ST_cmd_sql = "select top 10 * from ST_news where ST_n_iscmd=1 order by ST_n_id desc";

            string  sqlstr = "select ST_c_id,ST_c_name from ST_class";
            DataSet ST_ds  = myobj.GetDataSet(ST_sql, "ST_news");

            DataSet ST_classds = myobj.GetDataSet(sqlstr, "ST_class");

            DataSet ST_cmdds = myobj.GetDataSet(ST_cmd_sql, "ST_news");

            NewsShow.DataSource = ST_ds.Tables[0];
            NewsShow.DataBind();

            ClassList.DataSource = new DataView(ST_classds.Tables[0]);
            ClassList.DataBind();

            CmdList.DataSource = new DataView(ST_cmdds.Tables[0]);
            CmdList.DataBind();
            //调用ST_UpdateHit()方法
            ST_UpdateHit();
            if (Request.Cookies["colors"] != null)
            {
                string   ST_test      = Request.Cookies["colors"].Value;
                String[] ST_colorList = ST_test.Split(new[] { ',' });
                ST_bgcolor = ST_colorList[0];
                ST_tcolor  = ST_colorList[1];
            }
            else
            {
                ST_bgcolor = "#FFFFFF";
                ST_tcolor  = "#cccccc";
            }
            Page.DataBind();
        }