Exemple #1
0
    //protected void Page_Init(object sender, EventArgs e)
    //{
    //    if (this.CategoryId.HasValue)
    //    {
    //        int count = this.RebindCategories(this.CategoryId);
    //        this.categories.Visible = true;
    //        if (count == 0)
    //            this.pnlCategories.Visible = false;
    //    }
    //}

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (this.Display == RecipeDisplayEnum.ByCategory)
            {
                int count = this.RebindCategories(this.CategoryId);
                this.categories.Visible = true;
                if (count == 0)
                {
                    this.pnlCategories.Visible = false;
                }
            }
            //if (this.Display == RecipeDisplayEnum.BySearchSimple)
            //{
            //    this.simpleSearch.Visible = true;
            //    this.btnSearch.Visible = true;
            //    this.txtSearchTerm.Text = (!string.IsNullOrEmpty(Request["term"])) ? Request["term"] : "" ;
            //    this.btnSearch.CommandArgument = "BySearchSimple";
            //}
            if (this.Display == RecipeDisplayEnum.BySearchAdvanced)
            {
                //this.simpleSearch.Visible = true;
                this.advancedSearch.Visible = true;
                //this.btnSearch.Visible = true;
                //this.txtSearchTerm.Text = (!string.IsNullOrEmpty(Request["term"])) ? Request["term"] : "" ;
                this.txtServings.Text = (!string.IsNullOrEmpty(Request["serv"])) ? Request["serv"] : "";
                this.txtCategory.Text = "";
                //this.btnSearch.CommandArgument = "BySearchAdvanced";
            }

            EmphasizeCurrentSearch(this.Display);

            MyBuyList.Shared.Entities.User currentUser = BusinessFacade.Instance.GetUser(((BasePage)this.Page).UserId);
            string email = (currentUser != null) ? currentUser.Email : string.Empty;
            this.ucSendMailToFriend.BindItemDetails("Recipe", 0, string.Empty, email);

            RebindRecipes();

            // 13.10.2010
            // Load categories at page load
            Category[] categories = BusinessFacade.Instance.GetRecipesCategoriesList(((BasePage)this.Page).UserId);
            var        list       = from cat in categories.Where(cat => cat.ParentCategoryId == null).ToArray()
                                    select new SRL_Category(cat.CategoryId, cat.CategoryName, cat.ParentCategoryId, cat.RecipesCount);

            SRL_Category[] categoryList = list.ToArray();
            ReciepesSearchControl1.FillList(categoryList, this.RecipeCategoryChangeBaseUrl);
        }
    }