protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["page"] == null) { // new user form FormViewBlog.DefaultMode = FormViewMode.Insert; // set current user as author DropDownList ddlAuthor = (DropDownList)FormViewBlog.FindControl("BlogAuthor"); Author tempAuthor = AuthorManager.GetItem(User.Identity.Name); if (tempAuthor != null) { ddlAuthor.SelectedValue = tempAuthor.id.ToString(); } } else { // edit user form FormViewBlog.DefaultMode = FormViewMode.Edit; // pre-select author and tags Blogo.NET.Business.BlogEntry blogentry = BlogEntryManager.GetItem(long.Parse(Request.QueryString["page"].ToString())); DropDownList ddlAuthor = (DropDownList)FormViewBlog.FindControl("BlogAuthor"); if (blogentry.author != null) { ddlAuthor.SelectedValue = blogentry.author.id.ToString(); } CheckBoxList cblTags = (CheckBoxList)FormViewBlog.FindControl("BlogTags"); foreach (Tag t in blogentry.tags) { ListItem currentTag = cblTags.Items.FindByValue(t.id.ToString()); if (currentTag != null) { currentTag.Selected = true; } } } } }
protected void Page_Load(object sender, EventArgs e) { // hide comments listview and "new comment" panel // when comments are disabled for the current blog entry try { Blogo.NET.Business.BlogEntry myBlogEntry = BlogEntryManager.GetItem(long.Parse(Request.QueryString["page"])); if (myBlogEntry.allowcomments == false) { ListComments.Visible = false; PlaceHolderNewComment.Visible = false; PlaceHolderNoComments.Visible = true; } else { // if a blogo admin user is logged in, prefill comment name field with current user CommentName.Text = (User.Identity.IsAuthenticated ? User.Identity.Name : String.Empty); } } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { // Clear any previous output from the buffer Response.Clear(); Response.ContentType = "text/xml"; XmlTextWriter xtwFeed = new XmlTextWriter(Response.OutputStream, Encoding.UTF8); xtwFeed.WriteStartDocument(); // The mandatory rss tag xtwFeed.WriteStartElement("rss"); xtwFeed.WriteAttributeString("version", "2.0"); // The channel tag contains RSS feed details xtwFeed.WriteStartElement("channel"); xtwFeed.WriteElementString("title", BlogoSettings.RootPath + ":: Articles Feed"); xtwFeed.WriteElementString("link", BlogoSettings.RootPath + "/View/Pages/Home.aspx"); xtwFeed.WriteElementString("description", "The last articles from " + BlogoSettings.RootPath); xtwFeed.WriteElementString("copyright", "Copyright s3maphor3.org. All rights reserved."); List <Blogo.NET.Business.BlogEntry> rssEntries = BlogEntryManager.GetListType(Types.article, 0, BlogoSettings.RSSPageSize); // Loop through the content of the list and add them to the RSS feed foreach (Blogo.NET.Business.BlogEntry bEntry in rssEntries) { xtwFeed.WriteStartElement("item"); xtwFeed.WriteElementString("title", bEntry.title); xtwFeed.WriteElementString("description", bEntry.description); xtwFeed.WriteElementString("link", BlogoSettings.RootPath + "/View/Pages/BlogEntry.aspx?page=" + bEntry.id); xtwFeed.WriteElementString("pubDate", bEntry.datepublished.ToString()); xtwFeed.WriteEndElement(); } // Close all tags xtwFeed.WriteEndElement(); xtwFeed.WriteEndElement(); xtwFeed.WriteEndDocument(); xtwFeed.Flush(); xtwFeed.Close(); Response.End(); }
protected void SaveButton_Click(object sender, EventArgs e) { // create new blog object if this is a new user, retrieve existing blog object if one is being edited Blogo.NET.Business.BlogEntry blogentry = null; if (Request.QueryString["page"] == null) { // new user blogentry = new Blogo.NET.Business.BlogEntry(); blogentry.datecreated = System.DateTime.Now; blogentry.datepublished = System.DateTime.Now; } else { // edit user blogentry = BlogEntryManager.GetItem(long.Parse(Request.QueryString["page"].ToString())); } // build up blog entry object DropDownList ddlAuthor = (DropDownList)FormViewBlog.FindControl("BlogAuthor"); ListItem liAuthor = ddlAuthor.SelectedItem; blogentry.author = AuthorManager.GetItem(long.Parse(liAuthor.Value)); TextBox tbTitle = (TextBox)FormViewBlog.FindControl("BlogTitle"); blogentry.title = tbTitle.Text; TextBox tbDescription = (TextBox)FormViewBlog.FindControl("BlogDescription"); blogentry.description = tbDescription.Text; CheckBoxList cblTags = (CheckBoxList)FormViewBlog.FindControl("BlogTags"); ListItemCollection licTags = cblTags.Items; blogentry.tags.Clear(); foreach (ListItem liTag in licTags) { if (liTag.Selected) { Tag t = new Tag(); t.id = long.Parse(liTag.Value); t.tagname = liTag.Text; blogentry.tags.Add(t); } } RadioButtonList rblTyp = (RadioButtonList)FormViewBlog.FindControl("BlogType"); ListItem liType = rblTyp.SelectedItem; blogentry.type = (liType.Text.Equals(Types.article.ToString(), StringComparison.CurrentCultureIgnoreCase) ? Types.article : Types.blogentry); CheckBox cbAllowComments = (CheckBox)FormViewBlog.FindControl("BlogAllowComments"); blogentry.allowcomments = cbAllowComments.Checked; CheckBox cbMarkPrivate = (CheckBox)FormViewBlog.FindControl("BlogMarkPrivate"); blogentry.markprivate = cbMarkPrivate.Checked; TextBox tbBody = (TextBox)FormViewBlog.FindControl("BlogBody"); blogentry.body = tbBody.Text; blogentry.datemodified = System.DateTime.Now; // save blog entry to the database BlogEntryManager.Save(blogentry); Response.Redirect("~/View/Pages/Admin/Admin.aspx"); }