Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["category"] != null)
        {
            XMLForum forumDB = new XMLForum();

            // Cycle through each post in category that was clicked on
            foreach (String post in forumDB.getPosts((String)Session["category"]))
            {
                TableRow   row  = new TableRow();
                TableCell  cell = new TableCell();
                LinkButton link = new LinkButton();

                mainTable.Rows.Add(row);
                link.Text   = post;
                link.Click += new EventHandler(this.onPostClick);
                cell.Controls.Add(link);
                cell.Attributes.Add("class", "postsCell");
                row.Cells.Add(cell);
            }
        }
        else
        {
            Response.Redirect("Forum.aspx");
        }
    }
Пример #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        XMLForum forumDB = new XMLForum();

        String category = (String)Session["category"];
        String title    = (String)Session["post"];
        String message  = txtContent.Text;

        if ((title == "") || (message == ""))
        {
            return;
        }

        Dictionary <string, string> replyInfo = new Dictionary <string, string>();

        replyInfo.Add("content", message);
        replyInfo.Add("user", Request.Cookies["sessionID"].Value);

        forumDB.createReply(replyInfo, category, title);

        Response.Redirect("Post.aspx");
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["post"] != null)
        {
            XMLForum forumDB = new XMLForum();
            XMLUsers userDB  = new XMLUsers();

            TableRow  rowTitle        = new TableRow();
            TableRow  rowContent      = new TableRow();
            TableCell cellTitle       = new TableCell();
            TableCell cellBy          = new TableCell();
            TableCell cellContent     = new TableCell();
            TableCell cellReplyButton = new TableCell();

            Button btnReply = new Button();
            btnReply.Click += new EventHandler(this.onReplyClick);
            btnReply.Text   = "Reply";

            mainTable.Rows.Add(rowTitle);
            mainTable.Rows.Add(rowContent);

            String category = (String)Session["category"];
            String title    = (String)Session["post"];
            String postBy   = userDB.getUserFromSessionID(forumDB.getPostedBy(category, title));

            cellTitle.Text   = title;
            cellBy.Text      = "Posted by " + postBy;
            cellContent.Text = forumDB.readPost(category, title);
            cellReplyButton.Controls.Add(btnReply);

            cellTitle.Attributes.Add("class", "postTitle");
            cellBy.Attributes.Add("class", "postBy");
            cellReplyButton.Attributes.Add("class", "postBy");

            rowTitle.Cells.Add(cellTitle);
            rowTitle.Cells.Add(cellReplyButton);
            rowTitle.Attributes.Add("class", "postTitleRow");
            rowContent.Cells.Add(cellContent);
            rowContent.Cells.Add(cellBy);
            rowContent.Attributes.Add("class", "postContentRow");

            if (forumDB.getPostReplies(category, title) != null)
            {
                TableRow  rowReply;
                TableCell cellReplyContent;
                TableCell cellReplyBy;
                String    replyBy;

                foreach (var pair in forumDB.getPostReplies(category, title))
                {
                    rowReply         = new TableRow();
                    cellReplyContent = new TableCell();
                    cellReplyBy      = new TableCell();

                    mainTable.Rows.Add(rowReply);
                    rowReply.Attributes.Add("class", "postReplyRow");

                    replyBy = pair.Key;
                    replyBy = replyBy.Substring(0, replyBy.Length - 3);
                    replyBy = userDB.getUserFromSessionID(replyBy);

                    cellReplyContent.Text = pair.Value;
                    cellReplyBy.Text      = "Posted by " + replyBy;
                    cellReplyBy.Attributes.Add("class", "postBy");

                    rowReply.Cells.Add(cellReplyContent);
                    rowReply.Cells.Add(cellReplyBy);
                }
            }
        }
        else
        {
            Response.Redirect("Forum.aspx");
        }
    }