Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version
Go to top

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

, 9 Feb 2012
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)

Share

About the Author

Rahul Rajat Singh
Software Developer (Senior)
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[^]
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 9 Feb 2012
Article Copyright 2012 by Rahul Rajat Singh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid