MarkItUp.SingleUserBlog.Web/Posts/PostsByMonth.aspx.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MarkItUp.SingleUserBlog.Services;

public partial class Posts_PostsByMonth : System.Web.UI.Page {


    protected int Month {
        get { return (ViewState["Month"] == null) ? DateTime.Now.Month : (int)ViewState["Month"]; }
        set { ViewState["Month"] = value; }
    }


    protected int Year {
        get { return (ViewState["Year"] == null) ? DateTime.Now.Year : (int) ViewState["Year"]; }
        set { ViewState["Year"] = value; }
    }


    protected override void OnInit(EventArgs e) {
        base.OnInit(e);

        this.PostList.ItemTemplate = Page.LoadTemplate("~/UserControls/PostItemTemplate.ascx");
    }

    protected override void OnLoad(EventArgs e) {
        base.OnLoad(e);

        if (!IsPostBack) {
            if (Request.QueryString["m"] != null) {
                int month = DateTime.Now.Month;
                int.TryParse(Request.QueryString["m"].ToString(), out month);
                this.Month = month;
            }

            if (Request.QueryString["y"] != null) {
                int year = DateTime.Now.Year;
                int.TryParse(Request.QueryString["y"].ToString(), out year);
                this.Year = year;
            }
            
        }

        PostCollection posts = DataLayer.Instance.ListPostsByMonth(this.Year, this.Month);

        DateTime tmp = new DateTime(this.Year, this.Month, 1) ;

        this.lblCategoryTitle.InnerText = "Posts for: " + tmp.ToString("MMM yyyy");

        if (posts != null) {
            posts.Sort(false);

后面还有 5 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。