Example #1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            BlogCategoryDAL categoryDAL = new BlogCategoryDAL();
            BlogEntryDAL entryDAL = new BlogEntryDAL();

            //setup the accordion
            this.Accordion.Panes.Clear();
            foreach (BlogCategory category in categoryDAL.ReadBlogCategory(BlogTopic))
            {
                AjaxControlToolkit.AccordionPane pane = new AjaxControlToolkit.AccordionPane();
                pane.ID = "pane" + category.Id;

                LiteralControl header = new LiteralControl(string.Format("<div class = \"MenuHeader\"><b>{0}</b></div>", category.Category));

                pane.HeaderContainer.Controls.Add(header);
                pane.ContentContainer.Controls.Add(new LiteralControl("<ul style='margin-top:0; margin-bottom:0'>"));
                foreach (BlogEntry entry in entryDAL.GetBlogEntries(category.Id))
                {
                    LinkButton linkButton = new LinkButton();
                    linkButton.ID = "linkButton" + entry.Id;
                    linkButton.Text = entry.Subject;
                    linkButton.CommandArgument = entry.Id.ToString();
                    linkButton.Command += new CommandEventHandler(linkButton_Command);
                    linkButton.CausesValidation = false;
                    linkButton.CssClass = "MenuButton";
                    pane.ContentContainer.Controls.Add(new LiteralControl("<li>"));
                    pane.ContentContainer.Controls.Add(linkButton);
                    pane.ContentContainer.Controls.Add(new LiteralControl("</li>"));
                }
                pane.ContentContainer.Controls.Add(new LiteralControl("</ul>"));
                this.Accordion.Panes.Add(pane);
            }
        }
Example #2
0
 protected void lnkButton_Command(object sender, CommandEventArgs e)
 {
     BlogEntryDAL blogEntryDAL = new BlogEntryDAL();
     int Id = Convert.ToInt32(e.CommandArgument);
     BlogEntry blogEntry = blogEntryDAL.GetBlogEntry(Id);
     Response.Redirect(string.Format("/GUI/{0}?BlogEntryID={1}", blogEntry.BlogCategory.BlogTopic.PageName, blogEntry.Id));
 }
Example #3
0
        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int BlogEntryId = Convert.ToInt32(((GridView)sender).DataKeys[e.NewSelectedIndex].Value);
            BlogEntry entry = new BlogEntryDAL().GetBlogEntry(BlogEntryId);
            BlogCategory category = entry.BlogCategory;
            int BlogTopicId = category.FK_Topic;

            Response.Redirect(string.Format("CreateBlogEntry.aspx?Id={0}&BlogTopicID={1}", BlogEntryId, BlogTopicId));
            ;
        }
Example #4
0
 /// <summary>
 /// Occurs when user presses the links in the archive
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Archive_LinkButtonPressed(object sender, CommandEventArgs e)
 {
     int Id = Convert.ToInt32(e.CommandArgument);
     BlogEntryDAL blogEntryDAL = new BlogEntryDAL();
     BlogEntry blogEntry = blogEntryDAL.GetBlogEntry(Id);
     if (blogEntry != null)
     {
         string pageName = blogEntry.BlogCategory.BlogTopic.PageName;
         Response.Redirect(string.Format("/GUI/{0}?BlogEntryID={1}", pageName, Id));
     }
 }
        /// <summary>
        /// Checks whether there is a CurrentEntryID in the view state.
        /// If not, load default blog entry, otherwise load entry with the ID = CurrentEntryID.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void odsBlogEntry_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            if (ViewState["CurrentEntryID"] == null)
            {
                int BlogTopicId = new BlogTopicDAL().GetBlogTopicId(BlogTopic);
                BlogEntryDAL blogEntryDAL = new BlogEntryDAL();
                int Id = blogEntryDAL.GetDefaultBlogEntryId(BlogTopicId);
                e.InputParameters["Id"] = Id;

                ViewState.Add("CurrentEntryID", e.InputParameters["Id"]);
            }
            else
            {
                e.InputParameters["Id"] = ViewState["CurrentEntryID"];
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            if (user != null && user.UserName.ToLower() == "administrator" && user.IsOnline)
            {
                this.btnEdit.Visible = true;
            }
            else
            {
                this.btnEdit.Visible = false;
            }

            this.lblShowPopup.Visible = IsCommentsVisible;
            this.ModalPopupExtender1.Enabled = IsCommentsVisible;
            this.Popup.Visible = IsCommentsVisible;

            this.dvwEntry.Fields[1].Visible = IsPublishedDateVisible;

            BlogEntryDAL blogEntryDAL = new BlogEntryDAL();
            BlogEntry blogEntry;
            if (!IsPostBack)
            {
                int BlogEntryId = Convert.ToInt32(Request.Params["BlogEntryID"]);

                //if there is a request param, take it, otherwise get the default entry
                if (BlogEntryId != 0)
                {
                    blogEntry = blogEntryDAL.GetBlogEntry(BlogEntryId);
                }
                else
                {
                    blogEntry = blogEntryDAL.GetDefaultBlogEntry(BlogTopic);
                }

                //save the id of the blogEntry (if it exists) to the view state, in order that it is selected in the ods selecting event
                if (blogEntry != null)
                {
                    CurrentEntryID = blogEntry.Id.ToString();
                }
            }

            this.dvwBlogComment.ChangeMode(DetailsViewMode.Insert);
        }