Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Validate admin session username and password by comparing them to the admin user database record.
            UserNameVal.ValidateAdminUserNameandPass();

            //Get admin username from the sessioan variable and place it in the label.
            lblusername.Text = "Welcome Admin: " + UserNameVal.AdminUsername;

            if (Request.QueryString["prevedit"] != null)
            {
                btn1.Visible = false;
                btn2.Visible = true;
            }
            else
            {
                btn1.Visible = true;
                btn2.Visible = false;
            }

            //Instantiate database field
            ArticleDetail Article = new ArticleDetail();

            Article.WhatPageID = (int)Util.Val(Request.QueryString["show"]); //Parameter 2 = we are dealing with the admin/updatearticle.aspx.
            Article.ID         = (int)Util.Val(Request.QueryString["aid"]);

            //Fill up database fields
            Article.fillup();

            string categoryname;
            categoryname = Article.Category;

            lbtitle.Text    = Article.Title;
            lbcatname2.Text = Article.Category;
            Title.Value     = Article.Title;
            Content.Value   = Util.FormatText(Article.Content);
            Summary.Value   = Util.FormatText(Article.Summary);
            Keyword.Value   = Article.Keyword;
            Author.Value    = Article.Author;
            CAT_ID.Value    = Article.CatID.ToString();

            //Release allocated memory
            myBL    = null;
            Util    = null;
            Article = null;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate object
        Utility Util = new Utility();

        //Instantiate database field
        RecipeDetails Recipe = new RecipeDetails();

        Recipe.WhatPageID = constant.intRecipeDetails; //1 = we are dealing with print.aspx use the same as recipedetails.
        Recipe.ID = (int)Util.Val(Request.QueryString["id"]);

        //Fill up database fields
        Recipe.fillup();

        lblingredientsdis.Text = "Ingredients:";
        lblinstructionsdis.Text = "Instructions:";
        lblname.Text = Recipe.RecipeName;
        lblIngredients.Text = Util.FormatText(Recipe.Ingredients);
        lblInstructions.Text = Util.FormatText(Recipe.Instructions);

        strRName = "Printing" + Recipe.RecipeName + " Recipe";

        //Release allocated memory
        Util = null;
        Recipe = null;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate object
        Blogic myBL = new Blogic();

        //Instantiate object
        Utility Util = new Utility();

        int CatId = (int)Util.Val(Request.QueryString["catid"]);

        //Display random recipe
        GetRandomrecipe(CatId);

        //Get the newest 10 recipes. Change the value to 5 if you want to display only 5 newest recipes.
        int TopNewest = 10;

        //Get the 15 popular recipes. Change the value to 5 or 10 if you want to display only 5/10 most popular recipes.
        int TopPopular = 15;

        NewestRecipeSideMenuProvider GetNewestRecipe = new NewestRecipeSideMenuProvider(CatId, TopNewest);
        PopularRecipeSideMenuProvider GetPopularRecipe = new PopularRecipeSideMenuProvider(CatId, TopPopular);

        string CategoryName = GetNewestRecipe.Category;

        if (!string.IsNullOrEmpty(this.Request.QueryString["catid"]))
        {
            lblcatname.Text = CategoryName.ToString() + " ";
            lblcatnamepop.Text = CategoryName.ToString() + " ";
            lblrancatname.Text = CategoryName.ToString() + " ";
            lbTopCnt.Text = TopNewest.ToString();
        }
        else
        {
            lblcatname.Text = "";
            lbTopCnt.Text = TopNewest.ToString();
        }

        RecipeNew.DataSource = GetNewestRecipe.GetNewestRecipe();
        RecipeNew.DataBind();

        TopRecipe.DataSource = GetPopularRecipe.GetPopularRecipe();
        TopRecipe.DataBind();

        if (!string.IsNullOrEmpty(this.Request.QueryString["catid"]))
        {
            lblpopcounter.Text = "Top Recipes";
        }
        else
        {
            lblpopcounter.Text = "Top 15 Recipes";
        }

        //Release allocated memory
        GetNewestRecipe = null;
        GetPopularRecipe = null;
        Util = null;
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate object
        Utility Util = new Utility();

        //Initilaize rating variables
        int WhatPage = (int)Util.Val(Request.QueryString["wp"]); //Check what page to add the rating, either recipe or article.
        int ID = (int)Util.Val(Request.QueryString["id"]); //ID of the current item
        int RateValue = (int)Util.Val(Request.QueryString["rateval"]); //Rating value

        //Intantiate rating object
        Addrating Rating = new Addrating(WhatPage, ID, RateValue);

        Rating.Insert();

        //Release allocated memory
        Rating = null;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate utility/common object
        Utility Util = new Utility();

        Article.WhatPageID = constant.intArticleDetails;
        Article.ID = (int)Util.Val(Request.QueryString["aid"]);

        //Fill up article database fields
        Article.fillup();

        lblwordcount.Text = Utility.WordCount(Article.Content).ToString();

        lbtitle.Text = Article.Title;
        lbcontent.Text = Article.Content;
        lbhits.Text = string.Format("{0:#,###}", Article.Hits);
        lbauthor.Text = Article.Author;
        lblrating.Text = Article.Rating;
        lblvotescount.Text = Article.NoRates;
        starimage.ImageUrl = Utility.GetStarImage(Article.Rating);
        lbldate.Text = string.Format("{0:MMMM dd, yyyy}", Article.Date);

        //Save to Favorite/Bookmark URL.
        strBookmarkURL = Bookmark.URL;

        strArtTitle = Article.Title;
        strCatName = Article.Category;
        ArtCatId = Article.CatID;
        ArticleSection = constant.intArticle;

        //Get page title and keyword
        GetMetaTitleTagKeywords(strArtTitle, strCatName);

        //Get cooking article user rating
        GetUserCookingArticleRating();

        //Release allocated memory
        Util = null;
        Article = null;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate utility object
        Utility Util = new Utility();

        //Instantiate database field
        ArticleDetail Article = new ArticleDetail();

        Article.WhatPageID = constant.intArticleDetails; //Parameter 1 = we are dealing with the articledetail.aspx.
        Article.ID = (int)Util.Val(Request.QueryString["aid"]);

        //Fill up article database fields
        Article.fillup();

        lbtitle.Text = Article.Title;
        lbcontent.Text = Article.Content;
        strArtTitle = "Printing " + Article.Title + " article";

        //Release allocated memory
        Util = null;
        Article = null;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate utility object
            Utility Util = new Utility();

            int CatId, OrderBy, SortBy;
            OrderBy = (int)Util.Val(Request.QueryString["ob"]);
            SortBy = (int)Util.Val(Request.QueryString["sb"]);

            if (Request.QueryString["catid"] != null)
            {
                CatId = (int)Util.Val(Request.QueryString["catid"]);

                // Here we check what field are we going to sort, this depends on the sort value
                if (OrderBy == 1)
                {
                    LinkMostPopular.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort category by Most Popular ASC Order";
                    ArrowImage1.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage1.Visible = true;

                    if (SortBy == 2)
                    {
                        LinkMostPopular.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                        LinkMostPopular.Text = "Most Popular";
                        LinkMostPopular.ToolTip = "Sort category by Most Popular DESC order";
                        ArrowImage1.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage1.Visible = true;
                    }
                }
                else
                {
                    LinkMostPopular.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=1";
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort category by Most Popular";
                    ArrowImage1.Visible = false;
                }
                if (OrderBy == 2)
                {
                    LinkHighestRated.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by Highest Rated ASC Order";
                    ArrowImage2.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage2.Visible = true;

                    if (SortBy == 2)
                    {
                        LinkHighestRated.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                        LinkHighestRated.Text = "Highest Rated";
                        LinkHighestRated.ToolTip = "Sort category by Highest Rated DESC order";
                        ArrowImage2.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage2.Visible = true;
                    }
                }
                else
                {
                    LinkHighestRated.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=2";
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by Highest Rated";
                    ArrowImage2.Visible = false;
                }
                if (OrderBy == 3)
                {
                    LinkName.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort by article title DESC order";
                    ArrowImage3.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage3.Visible = true;

                    if (SortBy == 1)
                    {
                        LinkName.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                        LinkName.Text = "Name";
                        LinkName.ToolTip = "Sort by article title ASC order";
                        ArrowImage3.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage3.Visible = true;
                    }
                }
                else
                {
                    LinkName.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=3";
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort category by name";
                    ArrowImage3.Visible = false;
                }
                if (OrderBy == 4)
                {
                    LinkNewest.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort category by newest recipes ASC order";
                    ArrowImage4.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage4.Visible = true;

                    if (SortBy == 2)
                    {
                        LinkNewest.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                        LinkNewest.Text = "Newest";
                        LinkNewest.ToolTip = "Sort category by newest recipes DESC order";
                        ArrowImage4.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage4.Visible = true;
                    }
                }
                else
                {
                    LinkNewest.NavigateUrl = "~/articlecategory.aspx?catid=" + CatId + "&ob=4";
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort category by newest article";
                    ArrowImage4.Visible = false;

                }
            }

            if (Request.QueryString["find"] != null)
            {

                string strKeyword;

                CatId = (int)Util.Val(Request.QueryString["catid"]);
                strKeyword = Request.QueryString["find"].ToString();

                // Here we check what field are we going to sort, this depends the sort value
                if (OrderBy == 1)
                {
                    LinkMostPopular.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort by Most Popular ASC Order";
                    ArrowImage1.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage1.Visible = true;

                    if (SortBy == 2)
                    {
                        LinkMostPopular.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                        LinkMostPopular.Text = "Most Popular";
                        LinkMostPopular.ToolTip = "Sort category by Most Popular DESC order";
                        ArrowImage1.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage1.Visible = true;
                    }
                }
                else
                {
                    LinkMostPopular.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=1";
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort by Most Popular";
                    ArrowImage1.Visible = false;
                }
                if (OrderBy == 2)
                {
                    LinkHighestRated.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by Highest Rated ASC Order";
                    ArrowImage2.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage2.Visible = true;

                    if (SortBy == 2)
                    {
                        LinkHighestRated.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                        LinkHighestRated.Text = "Highest Rated";
                        LinkHighestRated.ToolTip = "Sort category by Highest Rated DESC order";
                        ArrowImage2.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage2.Visible = true;
                    }
                }
                else
                {
                    LinkHighestRated.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=2";
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by Highest Rated";
                    ArrowImage2.Visible = false;
                }
                if (OrderBy == 3)
                {
                    LinkName.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort by Name DESC Order";
                    ArrowImage3.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage3.Visible = true;

                    if (SortBy == 1)
                    {
                        LinkName.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                        LinkName.Text = "Name";
                        LinkName.ToolTip = "Sort category by Name ASC order";
                        ArrowImage3.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage3.Visible = true;
                    }
                }
                else
                {
                    LinkName.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=3";
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort by Name";
                    ArrowImage3.Visible = false;
                }
                if (OrderBy == 4)
                {
                    LinkNewest.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=2";
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort by Newest ASC Order";
                    ArrowImage4.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage4.Visible = true;

                    if (SortBy == 2)
                    {
                        LinkNewest.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy + "&sb=1";
                        LinkNewest.Text = "Newest";
                        LinkNewest.ToolTip = "Sort by Newest DESC order";
                        ArrowImage4.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage4.Visible = true;
                    }
                }
                else
                {
                    LinkNewest.NavigateUrl = "~/searcharticle.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=4";
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort by Newest";
                    ArrowImage4.Visible = false;
                }
            }
    }
    //Handles show edit article listing
    private void ShowEditArticleListing()
    {
        //Instantiate sql params object
        Blogic myBL = new Blogic();

        //Instantiate validation
        Utility Util = new Utility();

        int CatId;
        CatId = (int)Util.Val(Request.QueryString["catid"]);

        if (string.IsNullOrEmpty(this.Request.QueryString["catid"]))
        {
            Panel1.Visible = false;
        }
        else
        {
            Panel1.Visible = true;

            try
            {
                IDataReader dr = myBL.GetArticleCategory(CatId, 3); //3 = Category OrderBy Name.

                dr.Read();
                lbcatname.Text = dr["CAT_NAME"].ToString();
                dr.Close();

                ArticleCat.DataSource = myBL.GetArticleCategory(CatId, 3); //3 = Category OrderBy Name.
                ArticleCat.DataBind();
            }
            catch
            {
                Error.Text = "No Record Found.";
                return;
            }

            //Release allocated memory
            myBL = null;
            Util = null;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate validation
            Utility Util = new Utility();

            int OrderBy, Sort_By, iPage, Layout;
            OrderBy = (int)Util.Val(Request.QueryString["ob"]);
            Sort_By = (int)Util.Val(Request.QueryString["sb"]);

            if (string.IsNullOrEmpty(this.Request.QueryString["page"]))
            {
                iPage = 1; //If request pageindex is empty, assign pageindex of 1 = 1st page
            }
            else
            {
                iPage = (int)Util.Val(Request.QueryString["page"]); //Grab the querystring pageindex value
            }

            if (string.IsNullOrEmpty(this.Request.QueryString["layout"]))
            {
                Layout = 1;
            }
            else
            {
                Layout = (int)Util.Val(Request.QueryString["layout"]);
            }

         #region Sort option links for category.aspx
            //Handles the sort option links for the category.aspx
            if (!string.IsNullOrEmpty(Request.QueryString["catid"]))
            {
                int CatId;

                CatId = (int)Util.Val(Request.QueryString["catid"]);

                // Here we check what field are we going to sort, this depends on the sort value
                if (OrderBy == 1)
                {
                    LinkMostPopular.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort category by Most Popular ASC Order";
                    ArrowImage1.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage1.Visible = true;

                    if (Sort_By == 2)
                    {
                        LinkMostPopular.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkMostPopular.Text = "Most Popular";
                        LinkMostPopular.ToolTip = "Sort category by Most Popular DESC Order";
                        ArrowImage1.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage1.Visible = true;
                    }
                }
                else
                {
                    LinkMostPopular.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=1" + "&sb=" + Sort_By + "&page=" + iPage + "&layout=" + Layout;
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort category by Most Popular";
                    ArrowImage1.Visible = false;
                }

                if (OrderBy == 2)
                {
                    LinkHighestRated.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort category by highest rated ASC order";
                    ArrowImage2.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage2.Visible = true;

                    if (Sort_By == 2)
                    {
                        LinkHighestRated.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkHighestRated.Text = "Highest Rated";
                        LinkHighestRated.ToolTip = "Sort category by highest rated DESC order";
                        ArrowImage2.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage2.Visible = true;
                    }
                }
                else
                {
                    LinkHighestRated.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=2" + "&sb=" + Sort_By + "&page=" + iPage + "&layout=" + Layout;
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort category by highest rated";
                    ArrowImage2.Visible = false;
                }

                if (OrderBy == 3)
                {
                    LinkName.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort recipe by name DESC order";
                    ArrowImage3.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage3.Visible = true;

                    if (Sort_By == 1)
                    {
                        LinkName.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                        LinkName.Text = "Name";
                        LinkName.ToolTip = "Sort recipe by name ASC order";
                        ArrowImage3.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage3.Visible = true;
                    }
                }
                else
                {
                    LinkName.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=3" + "&sb=" + Sort_By + "&page=" + iPage + "&layout=" + Layout;
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort category by name";
                    ArrowImage3.Visible = false;
                }

                if (OrderBy == 4)
                {
                    LinkNewest.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort category by newest recipes ASC order";
                    ArrowImage4.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage4.Visible = true;

                    if (Sort_By == 2)
                    {
                        LinkNewest.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkNewest.Text = "Newest";
                        LinkNewest.ToolTip = "Sort category by newest recipes DESC order";
                        ArrowImage4.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage4.Visible = true;
                    }
                }
                else
                {
                    LinkNewest.NavigateUrl = "~/category.aspx?catid=" + CatId + "&ob=4&sb=" + Sort_By + "&page=" + iPage + "&layout=" + Layout;
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort category by newest recipes";
                    ArrowImage4.Visible = false;

                }
            }
          #endregion

         #region Sort option links for sort.aspx - most popular
            //Handles the sort option links for the sort.aspx
            if (!string.IsNullOrEmpty(Request.QueryString["sid"]))
            {
                int SortBy, SBy;

                SortBy = (int)Util.Val(Request.QueryString["sid"]);
                SBy = (int)Util.Val(Request.QueryString["sb"]);

                // Here we check what field are we going to sort, this depends the sort value
                if (SortBy == 1)
                {
                    LinkMostPopular.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort by 60 Most Popular ASC order";
                    ArrowImage1.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage1.Visible = true;

                    if (SBy == 2)
                    {
                        LinkMostPopular.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkMostPopular.Text = "Most Popular";
                        LinkMostPopular.ToolTip = "Sort by 60 Most Popular DESC order";
                        ArrowImage1.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage1.Visible = true;
                    }
                }
                else
                {
                    LinkMostPopular.NavigateUrl = "~/sort.aspx?sid=1&sb=" + SBy + "&page=" + iPage + "&layout=" + Layout;
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort by 60 Most Popular";
                    ArrowImage1.Visible = false;
                }

                if (SortBy == 2)
                {
                    LinkHighestRated.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by 60 Highest Rated Recipes ASC order";
                    ArrowImage2.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage2.Visible = true;

                    if (SBy == 2)
                    {
                        LinkHighestRated.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkHighestRated.Text = "Highest Rated";
                        LinkHighestRated.ToolTip = "Sort by 60 Highest Rated Recipes DESC order";
                        ArrowImage2.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage2.Visible = true;
                    }
                }
                else
                {
                    LinkHighestRated.NavigateUrl = "~/sort.aspx?sid=2&sb=" + SBy + "&page=" + iPage + "&layout=" + Layout;
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by 60 Highest Rated";
                    ArrowImage2.Visible = false;
                }
                if (SortBy == 3)
                {
                    LinkName.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort by name DESC order";
                    ArrowImage3.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage3.Visible = true;

                    if (SBy == 1)
                    {
                        LinkName.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                        LinkName.Text = "Name";
                        LinkName.ToolTip = "Sort by name ASC order";
                        ArrowImage3.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage3.Visible = true;
                    }
                }
                else
                {
                    LinkName.NavigateUrl = "~/sort.aspx?sid=3&sb=" + SBy + "&page=" + iPage + "&layout=" + Layout;
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort by name";
                    ArrowImage3.Visible = false;
                }
                if (SortBy == 4)
                {
                    LinkNewest.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort by 60 Newest Recipes ASC order";
                    ArrowImage4.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage4.Visible = true;

                    if (SBy == 2)
                    {
                        LinkNewest.NavigateUrl = "~/sort.aspx?sid=" + SortBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkNewest.Text = "Newest";
                        LinkNewest.ToolTip = "Sort by 60 Newest Recipes DESC order";
                        ArrowImage4.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage4.Visible = true;
                    }
                }
                else
                {
                    LinkNewest.NavigateUrl = "~/sort.aspx?sid=4&sb=" + SBy + "&page=" + iPage + "&layout=" + Layout;
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort by 60 Newest Recipes";
                    ArrowImage4.Visible = false;

                }
            }
            #endregion

         #region Sort option links for recipename.aspx
            //Handles the sort option links for the recipename.aspx
            if (!string.IsNullOrEmpty(Request.QueryString["letter"]))
            {
                string letter;
                int Sby = (int)Util.Val(Request.QueryString["sb"]);

                letter = Request.QueryString["letter"].ToString();

                // Here we check what field are we going to sort, this depends the sort value
                if (OrderBy == 1)
                {
                    LinkMostPopular.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort by Most Popular ASC order";
                    ArrowImage1.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage1.Visible = true;

                    if (Sby == 2)
                    {
                        LinkMostPopular.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkMostPopular.Text = "Most Popular";
                        LinkMostPopular.ToolTip = "Sort by Most Popular DESC order";
                        ArrowImage1.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage1.Visible = true;
                    }
                }
                else
                {
                    LinkMostPopular.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=1&sb=" + Sby + "&page=" + iPage + "&layout=" + Layout;
                    LinkMostPopular.Text = "Most Popular";
                    LinkMostPopular.ToolTip = "Sort by Most Popular";
                    ArrowImage1.Visible = false;
                }

                if (OrderBy == 2)
                {
                    LinkHighestRated.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by highest rated ASC order";
                    ArrowImage2.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage2.Visible = true;

                    if (Sby == 2)
                    {
                        LinkHighestRated.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkHighestRated.Text = "Highest Rated";
                        LinkHighestRated.ToolTip = "Sort by highest rated DESC order";
                        ArrowImage2.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage2.Visible = true;
                    }
                }
                else
                {
                    LinkHighestRated.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=2&sb=" + Sby + "&page=" + iPage + "&layout=" + Layout;
                    LinkHighestRated.Text = "Highest Rated";
                    LinkHighestRated.ToolTip = "Sort by highest rated";
                    ArrowImage2.Visible = false;
                }
                if (OrderBy == 3)
                {
                    LinkName.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort by name DESC order";
                    ArrowImage3.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage3.Visible = true;

                    if (Sby == 1)
                    {
                        LinkName.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                        LinkName.Text = "Name";
                        LinkName.ToolTip = "Sort by name ASC order";
                        ArrowImage3.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage3.Visible = true;
                    }
                }
                else
                {
                    LinkName.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=3&sb=" + Sby + "&page=" + iPage + "&layout=" + Layout;
                    LinkName.Text = "Name";
                    LinkName.ToolTip = "Sort by name";
                    ArrowImage3.Visible = false;
                }
                if (OrderBy == 4)
                {
                    LinkNewest.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=2&page=" + iPage + "&layout=" + Layout;
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort by newest recipes ASC order";
                    ArrowImage4.ImageUrl = Util.SortOptionArrowImage;
                    ArrowImage4.Visible = true;

                    if (Sby == 2)
                    {
                        LinkNewest.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=" + OrderBy + "&sb=1&page=" + iPage + "&layout=" + Layout;
                        LinkNewest.Text = "Newest";
                        LinkNewest.ToolTip = "Sort by newest recipes DESC order";
                        ArrowImage4.ImageUrl = Util.SortOptionArrowUpImage;
                        ArrowImage4.Visible = true;
                    }
                }
                else
                {
                    LinkNewest.NavigateUrl = "~/recipename.aspx?letter=" + letter + "&ob=4&sb=" + Sby + "&page=" + iPage + "&layout=" + Layout;
                    LinkNewest.Text = "Newest";
                    LinkNewest.ToolTip = "Sort by newest recipes";
                    ArrowImage4.Visible = false;

                }
            }
            #endregion

         #region Sort option links for search.aspx
         //Handles the sort option links for the search.aspx
         if (!string.IsNullOrEmpty(Request.QueryString["find"]))
         {
             int CatId;
             string strKeyword;

            CatId = (int)Util.Val(Request.QueryString["catid"]);
            strKeyword = Request.QueryString["find"].ToString();

        // Here we check what field are we going to sort, this depends the sort value
        if (OrderBy == 1)
        {
            LinkMostPopular.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy;
            LinkMostPopular.Text = "Most Popular";
            LinkMostPopular.ToolTip = "Sort by Most Popular";
            ArrowImage1.ImageUrl = Util.SortOptionArrowImage;
            ArrowImage1.Visible = true;
        }
        else
        {
            LinkMostPopular.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=1";
            LinkMostPopular.Text = "Most Popular";
            LinkMostPopular.ToolTip = "Sort by Most Popular";
            ArrowImage1.Visible = false;
        }
        if (OrderBy == 2)
        {
            LinkHighestRated.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy;
            LinkHighestRated.Text = "Highest Rated";
            LinkHighestRated.ToolTip = "Sort by highest rated";
            ArrowImage2.ImageUrl = Util.SortOptionArrowImage;
            ArrowImage2.Visible = true;
        }
        else
        {
            LinkHighestRated.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=2";
            LinkHighestRated.Text = "Highest Rated";
            LinkHighestRated.ToolTip = "Sort by highest rated";
            ArrowImage2.Visible = false;
        }
        if (OrderBy == 3)
        {
            LinkName.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy;
            LinkName.Text = "Name";
            LinkName.ToolTip = "Sort by name";
            ArrowImage3.ImageUrl = Util.SortOptionArrowImage;
            ArrowImage3.Visible = true;
        }
        else
        {
            LinkName.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=3";
            LinkName.Text = "Name";
            LinkName.ToolTip = "Sort by name";
            ArrowImage3.Visible = false;
        }
        if (OrderBy == 4)
        {
            LinkNewest.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=" + OrderBy;
            LinkNewest.Text = "Newest";
            LinkNewest.ToolTip = "Sort by newest recipes";
            ArrowImage4.ImageUrl = Util.SortOptionArrowImage;
            ArrowImage4.Visible = true;
        }
        else
        {
            LinkNewest.NavigateUrl = "~/searchrecipe.aspx?find=" + strKeyword + "&catid=" + CatId + "&ob=4";
            LinkNewest.Text = "Newest";
            LinkNewest.ToolTip = "Sort by newest recipes";
            ArrowImage4.Visible = false;

        }
           }
           #endregion
    }
    //Handles comment posting
    public void Add_Comment(Object s, EventArgs e)
    {
        //Perform spam validation by matching the value of the textbox security code to the session variable
        //that store the random number.
        if (Page.IsValid && (txtsecfield.Text.ToString() == Session["randomStr"].ToString()))
        {
            //Instantiate object
            Utility Util = new Utility();

            //If all the fields are filled correctly, then process the comment post.
            //Instantiate the SQL command object
            CommentInfo AddComm = new CommentInfo();

            AddComm.ID = (int)Util.Val(Request.QueryString["id"]);

            //Filters harmful scripts from input string.
            AddComm.Author = Util.FormatTextForInput(Request.Form[AUTHOR.UniqueID]);
            AddComm.Email = Util.FormatTextForInput(Request.Form[EMAIL.UniqueID]);
            AddComm.Comments = Util.FormatTextForInput(Request.Form[COMMENTS.UniqueID]);

            #region Comment Form Input Validator
            //Validate for empty name
            if (AddComm.Author.Length == 0)
            {
                JSLiteral.Text = Util.JSAlert("Error: Name is empty, please enter your name.");
                lbvalenght.Text = "<br>Error: Name is empty, please enter your name.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }
            //Validate for empty email
            if (AddComm.Email.Length == 0)
            {
                JSLiteral.Text = Util.JSAlert("Error: Email is empty, please enter your email.");
                lbvalenght.Text = "<br>Error: Email is empty, please enter your email.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }
            //Validate for empty comments
            if (AddComm.Comments.Length == 0)
            {
                JSLiteral.Text = Util.JSAlert("Error: Comment is empty, please your comment.");
                lbvalenght.Text = "<br>Error: Comment is empty, please your comment.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            //Name maximum of 50 char allowed
            if (AddComm.Author.Length > 50)
            {
                JSLiteral.Text = Util.JSAlert("Error: Name is too long. Max of 50 characters.");
                lbvalenght.Text = "<br>Error: Name is too long. Max of 50 characters.";
                lbvalenght.Visible = true;
                AUTHOR.Value = "";
                txtsecfield.Text = "";
                return;
            }
            //Email maximum of 50 char allowed
            if (AddComm.Email.Length > 50)
            {
                JSLiteral.Text = Util.JSAlert("Error: Email is too long. Max of 50 characters.");
                lbvalenght.Text = "<br>Error: Email is too long. Max of 50 characters.";
                lbvalenght.Visible = true;
                EMAIL.Value = "";
                txtsecfield.Text = "";
                return;
            }
            //Comments maximum of 200 char allowed
            if (AddComm.Comments.Length > 200)
            {
                JSLiteral.Text = Util.JSAlert("Error: Comments is too long. Max of 200 characters.");
                lbvalenght.Text = "<br>Error: Comments is too long. Max of 200 characters.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }
            #endregion

            //Notify user if error occured.
            if (AddComm.Add() != 0)
            {
                JSLiteral.Text = Util.JSAlert("A database error occured while processing your request.");
                return;
            }

            //Instantiate email template object
            EmailTemplate SendEmail = new EmailTemplate();

            SendEmail.ItemID = AddComm.ID;
            SendEmail.ItemName = strRName;

            //Send an email notification to the webmaster in HTML format.
            SendEmail.SendEmailCommentNotify();

            //Release allocated memory
            SendEmail = null;
            AddComm = null;

            //If success, redirect to confirmation and thank you page.
            Util.PageRedirect(4);

            Util = null;
        }
        else
        {
            //Javascript validation
            JSLiteral.Text = Util.JSAlert("Invalid security code. Make sure you type it correctly.");
            return;

           // lblinvalidsecode.Text = "Invalid security code. Make sure you type it correctly.";
           // lblinvalidsecode.Visible = true;
        }
    }