Click here to Skip to main content
15,884,298 members
Articles / Web Development / ASP.NET

YaBlogEngine - A Tiny Blog Engine written in ASP.NET/C#

Rate me:
Please Sign up or sign in to vote.
4.94/5 (20 votes)
9 Feb 2012CPOL4 min read 107.9K   6.5K   47  
YaBlogEngine is a Tiny Blog Engine written in ASP.NET/C#
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 System.Text;
using YABlog.BLL;

public partial class ViewEntry : System.Web.UI.Page
{
    EntriesAction ent = new EntriesAction();
    CommentsAction com = new CommentsAction();
    EntryBO entry = null;
    CategoriesAction cat = new CategoriesAction();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("default.aspx");
            }

        }             

        entry = ent.GetEntryDetails(Convert.ToInt32(Request.QueryString["id"]));

        Label1.Text = entry.Subject;
        Label2.Text = "Category: " + entry.Category + ", Posted on: " + entry.Date.ToString();

        string body = Format(entry.Body);
        Literal1.Text = Server.HtmlDecode(body);

        int commentCount = com.GetCommentsByEntry(Convert.ToInt32(Request.QueryString["id"]), Repeater1);

        Label3.Text = commentCount.ToString();        
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if(TextBox1.Text == "" || TextBox2.Text=="")
        {
            return;
        }

        bool ret = com.AddComment(Convert.ToInt32(Request.QueryString["id"]), TextBox1.Text, TextBox2.Text);

        if (ret == true)
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            
            Page_Load(this, new EventArgs());
        }
    }

    public string Format(string s)
    {
        string body = s;
        body = body.Replace("\r\n", "<br/>");
        body = body.Replace("  ", "&nbsp&nbsp");

        return body;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("updateentry.aspx?id=" + Request.QueryString["id"]);
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India

I Started my Programming career with C++. Later got a chance to develop Windows Form applications using C#. Currently using C#, ASP.NET & ASP.NET MVC to create Information Systems, e-commerce/e-governance Portals and Data driven websites.

My interests involves Programming, Website development and Learning/Teaching subjects related to Computer Science/Information Systems. IMO, C# is the best programming language and I love working with C# and other Microsoft Technologies.

  • Microsoft Certified Technology Specialist (MCTS): Web Applications Development with Microsoft .NET Framework 4
  • Microsoft Certified Technology Specialist (MCTS): Accessing Data with Microsoft .NET Framework 4
  • Microsoft Certified Technology Specialist (MCTS): Windows Communication Foundation Development with Microsoft .NET Framework 4

If you like my articles, please visit my website for more: www.rahulrajatsingh.com[^]

  • Microsoft MVP 2015

Comments and Discussions