Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user = Session["CurrentUser"] as User;
            mbh  = new MeassageBoradHelper();

            if (!IsPostBack)
            {
                this.MBcategories.Items.Clear();
                this.MBcategories.DataSource     = MeassageBoradHelper.GetCategories();
                this.MBcategories.DataTextField  = "CategoriesTitle";
                this.MBcategories.DataValueField = "CategoriesId";
                this.MBcategories.DataBind();
            }

            GetPageIndex();
            this.pagingAllPage.InnerHtml = "一共有" + mbh.paging.AllPage.ToString() + "页数据";
            divMassageBorad.InnerHtml    = mbh.GetTopPage();
            ulMBCategories.InnerHtml     = MeassageBoradHelper.GetMessageBoradCategories();

            if (user != null)
            {
                if (user.name.Length > 0)
                {
                    this.userName.InnerHtml = user.name;
                }
            }
        }
Exemplo n.º 2
0
        //留言发表
        protected void btnPublish_ServerClick(object sender, EventArgs e)
        {
            string comment = this.txtComment.Value.Trim();
            string title   = this.txtTitile.Value.Trim();

            if (user == null)
            {
                this.spPublishReult.InnerHtml = "<a style=\"color:red; \">请登录后尝试! </a>";
            }
            else
            {
                string str      = string.Empty;
                bool   isRePost = false;
                switch (MeassageBoradHelper.PublishAnArticle(user.id, title, comment, int.Parse(this.MBcategories.SelectedValue)))
                {
                case 0:
                    str      = "<a>发布成功!</a>";
                    isRePost = true;
                    break;

                case 1:
                    str = "<a>发布失败!请重新再试!</a>";
                    break;

                default:
                    str = "<a style=\"color:Red\">请输入内容!</a>";
                    break;
                }
                if (isRePost)
                {
                    Response.Redirect("MassageBoard.aspx");
                }
                else
                {
                    this.spPublishReult.InnerHtml = str;
                }
            }
        }