protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["Plan"] = new Plan(); } else { Plan plan = Session["Plan"] as Plan; lblResult.Text = "Plan.Recipes.count: " + plan.Recipes.Count.ToString() + "<br>"; lblResult.Text += "Plan.RecipeIngredients.Count: " + plan.RecipeIngredients.Count.ToString(); foreach (RecipeIngredient recipeIngredient in plan.RecipeIngredients) { CheckBox checkBox = new CheckBox { ID = recipeIngredient.RecipeIngredientID, Text = recipeIngredient.Ingredient.Description }; plhIngredients.Controls.Add(checkBox); plhIngredients.Controls.Add(new LiteralControl("<br>")); } } rptAllRecipes.DataSource = Recipe.AllRecipes(); rptAllRecipes.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Context.User.Identity.GetUserName() != "NoBrainerMeals") { Response.Redirect("NotAuthorized.aspx"); } if (!IsPostBack) { if (string.IsNullOrEmpty(Request.QueryString["RecipeID"])) { rptSelectRecipe.DataSource = Recipe.AllRecipes(); rptSelectRecipe.DataBind(); } else { Recipe recipe = new Recipe(Request.QueryString["RecipeID"]); lblTitle.Text += " to " + recipe.Name; pnlSelectRecipe.Visible = false; pnlLink.Visible = true; cblRecipes.DataSource = Recipe.AllRecipes(); cblRecipes.DataTextField = "Name"; cblRecipes.DataValueField = "RecipeID"; cblRecipes.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Context.User.Identity.GetUserName() != "NoBrainerMeals") { Response.Redirect("NotAuthorized.aspx"); } if (string.IsNullOrEmpty(Request.QueryString["RecipeID"])) { rptRecipeList.DataSource = Recipe.AllRecipes(); rptRecipeList.DataBind(); } else { if (!IsPostBack) { Recipe recipe = new Recipe(Request.QueryString["RecipeID"]); FillForm(recipe); } } }
protected void Page_Load(object sender, EventArgs e) { if (Context.User.Identity.GetUserName() != "NoBrainerMeals") { Response.Redirect("NotAuthorized.aspx"); } //if (!IsPostBack) { if (string.IsNullOrEmpty(Request.QueryString["RecipeID"])) { rptRecipe.DataSource = Recipe.AllRecipes(); rptRecipe.DataBind(); } else { Recipe recipe = new Recipe(Request.QueryString["RecipeID"]); pnlForm.Visible = true; pnlSelect.Visible = false; if (!IsPostBack) { for (int i = 1; i <= 15; i++) { DropDownList list = this.Master.FindControl("MainContent").FindControl("ddlIngredientUnit" + i) as DropDownList; list.DataSource = bp2.Models.Unit.Units; list.DataTextField = "Name"; list.DataValueField = "UnitID"; list.DataBind(); DropDownList list2 = this.Master.FindControl("MainContent").FindControl("ddlRecipeIngredientUnit" + i) as DropDownList; list2.DataSource = bp2.Models.Unit.Units; list2.DataTextField = "Name"; list2.DataValueField = "UnitID"; list2.DataBind(); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (Context.User.Identity.GetUserName() != "NoBrainerMeals") { Response.Redirect("NotAuthorized.aspx"); } if (string.IsNullOrEmpty(Request.QueryString["PhotoType"]) || string.IsNullOrEmpty(Request.QueryString["ID"])) { pnlRecipe.Visible = true; pnlSelect.Visible = false; rptRecipe.DataSource = Recipe.AllRecipes(); rptRecipe.DataBind(); } else { Recipe recipe = new Recipe(Request.QueryString["ID"]); rptPhotos.DataSource = recipe.Photos; rptPhotos.DataBind(); lblName.Text = recipe.Name + " " + recipe.Photos.Count; } }
protected void Page_Load(object sender, EventArgs e) { int page = Convert.ToInt32(Request.QueryString["Page"]); string sort = Request.QueryString["sort"]; if (page < 1) { page = 1; } switch (sort) { //case "Recent": //rptRecipes.DataSource = Recipe.RecentRecipes((page-1) * 8); //break; case "Rating": rptRecipes.DataSource = Recipe.RecipeRatings((page - 1) * 8); hlkRating.Enabled = false; hlkRating.CssClass = "bolder"; break; case "Popular": rptRecipes.DataSource = Recipe.Popular((page - 1) * 8); hlkPopular.Enabled = false; hlkPopular.CssClass = "bolder"; break; default: rptRecipes.DataSource = Recipe.AllRecipes((page - 1) * 8); hlkName.Enabled = false; hlkName.CssClass = "bolder"; break; } rptRecipes.DataBind(); //SET PAGE # LINKS int totalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(Recipe.AllRecipes().Count) / 8)); for (var i = 1; i <= totalPages; i++) { if (i == page) { plhPages.Controls.Add(new LiteralControl("<strong>Page " + i + "</strong>")); } else { HtmlAnchor htmlAnchor = new HtmlAnchor { HRef = "RecipeList.aspx?Sort=" + Request.QueryString["Sort"] + "&Page=" + i, InnerText = "Page " + i, }; plhPages.Controls.Add(htmlAnchor); } if (i != totalPages) { plhPages.Controls.Add(new LiteralControl(" | ")); } //SET ARROW BUTTONS if (page == 1) { btnPrevious.Visible = false; } else { btnPrevious.NavigateUrl = "RecipeList.aspx?Sort=" + Request.QueryString["Sort"] + "&Page=" + (page - 1).ToString(); } if (page == totalPages) { btnNext.Visible = false; } else { btnNext.NavigateUrl = "RecipeList.aspx?Sort=" + Request.QueryString["Sort"] + "&Page=" + (page + 1).ToString(); } } }