Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <Posts_M> postlist = Posts_B.PostList();

            rptPostList.DataSource = postlist;
            rptPostList.DataBind();
            //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('欢迎')</script>");
        }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Request.QueryString["TaxID"]))
     {
         string     TaxID = Request.QueryString["TaxID"];
         Taxonomy_M tax   = Taxonomy_B.getTaxonomyByID(TaxID);
         txtTax.Text            = tax.TaxonomyName;
         rptPostList.DataSource = Posts_B.PostListByTaxID(TaxID);
         rptPostList.DataBind();
     }
 }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         navPostRpt.DataSource = Posts_B.PostListTop3();
         navPostRpt.DataBind();
         navTaxRpt.DataSource = Taxonomy_B.TaxListTop2();
         navTaxRpt.DataBind();
         RptComments.DataSource = Comments_B.CommentsListTop3();
         RptComments.DataBind();
     }
 }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Posts_B.countPost() > 0)
     {
         post.Text = Posts_B.countPost().ToString() + "篇文章";
     }
     if (Comments_B.commentCount() > 0)
     {
         comment.Text = Comments_B.commentCount().ToString() + "条评论";
     }
     if (Taxonomy_B.TaxCount() > 0)
     {
         cate.Text = Taxonomy_B.TaxCount().ToString() + "个分类";
     }
 }
Exemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int order = Posts_B.PostList().Count();
         pagerPost.RecordCount = order;
         Bind();
     }
     if (!string.IsNullOrWhiteSpace(Request.QueryString["postId"]))
     {
         if (Posts_B.delBypostId(Request.QueryString["postId"]))
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除成功');location.href='AdminPost.aspx';</script>");
         }
     }
 }
Exemplo n.º 6
0
        protected void RptComments_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HiddenField UserID    = e.Item.FindControl("UserID") as HiddenField;
            HiddenField PostID    = e.Item.FindControl("PostID") as HiddenField;
            Label       UserName  = e.Item.FindControl("UserName") as Label;
            Label       PostTitle = e.Item.FindControl("PostTitle") as Label;

            if (!string.IsNullOrWhiteSpace(UserID.Value))
            {
                UserName.Text = Users_B.UserByID(UserID.Value).Username;
            }
            if (!string.IsNullOrWhiteSpace(PostID.Value))
            {
                PostTitle.Text = Posts_B.PostByID(PostID.Value).Title;
            }
        }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Request.QueryString["PostId"]))
     {
         Posts_M Post = Posts_B.PostByID(Request.QueryString["PostId"]);
         Page.Title       = Post.Title;
         lblTitle.Text    = Post.Title;
         PostDesc.Text    = Post.Post;
         PublishTime.Text = Post.PublishTime.ToShortDateString();
         int CategoryId = Post.TaxonomyId;
         CategoryName.Text = Taxonomy_B.getTaxonomyByID(CategoryId.ToString()).TaxonomyName;
     }
     else
     {
         Response.Redirect("Index.aspx");
     }
 }
Exemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ddlcate.DataSource     = Taxonomy_B.TaxList();
         ddlcate.DataValueField = "TaxonomyId";
         ddlcate.DataTextField  = "TaxonomyName";
         ddlcate.DataBind();
         if (!string.IsNullOrWhiteSpace(Request.QueryString["postId"]))
         {
             Posts_M post = Posts_B.PostByID(Request.QueryString["postId"]);
             txtTitle.Text   = post.Title;
             ddlcate.Text    = post.TaxonomyId.ToString();
             postdesc.Text   = post.Post;
             btnaddpost.Text = "修改";
         }
     }
 }
Exemplo n.º 9
0
        protected void CommentList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HiddenField UserId   = e.Item.FindControl("UserId") as HiddenField;
            Label       userName = e.Item.FindControl("userName") as Label;

            if (!string.IsNullOrWhiteSpace(UserId.Value))
            {
                Users_M user = Users_B.UserByID(UserId.Value);
                userName.Text = user.Username;
            }
            HiddenField PostId    = e.Item.FindControl("PostId") as HiddenField;
            Label       PostTitle = e.Item.FindControl("PostTitle") as Label;

            if (!string.IsNullOrWhiteSpace(PostId.Value))
            {
                Posts_M post = Posts_B.PostByID(PostId.Value);
                PostTitle.Text = post.Title;
            }
        }
Exemplo n.º 10
0
 protected void btnaddpost_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Request.QueryString["postId"]))
     {
         Posts_M post = new Posts_M();
         post.PostId     = Convert.ToInt32(Request.QueryString["postId"]);
         post.Title      = txtTitle.Text;
         post.TaxonomyId = Convert.ToInt32(ddlcate.Text);
         post.Post       = postdesc.Text;
         if (Posts_B.updatePost(post))
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('修改成功');location.href='AdminPost.aspx';</script>");
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('修改失败');</script>");
         }
     }
     else
     {
         Posts_M post = new Posts_M();
         post.Title      = txtTitle.Text;
         post.TaxonomyId = Convert.ToInt32(ddlcate.Text);
         post.Post       = postdesc.Text;
         if (Posts_B.addPost(post))
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功');</script>");
             txtTitle.Text = "";
             postdesc.Text = "";
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加失败');</script>");
         }
     }
 }
Exemplo n.º 11
0
 void Bind()
 {
     postList.DataSource = Posts_B.PostListPager(pagerPost.PageSize.ToString(), pagerPost.CurrentPageIndex.ToString());
     postList.DataBind();
 }