protected void Button1_Click(object sender, EventArgs e) { foreach (Control ctl in PlaceHolder1.Controls) { try { admin_controls_ctlEditItem item = (admin_controls_ctlEditItem)ctl; item.SaveItem(); } catch { // not an editable item :) } } Response.Redirect(Request.RawUrl); }
private void addControl(int controlId) { tblControls ctl = new tblControls(); ctl.LoadByPrimaryKey(controlId); int start = PlaceHolder1.Controls.Count; PlaceHolder1.Controls.Add(new LiteralControl("<h2>" + ctl.ControlFriendlyName)); if (((int)UserContext.GetContextItemAsInt("userlevel") == 1) && (!ctl.Custom)) { HyperLink hl = new HyperLink(); hl.Text = "Add New Item »"; hl.NavigateUrl = epicCMSLib.Navigation.PopupPageLink("AddItem.aspx?ctl=" + controlId.ToString() + "&langId=" + Request["langId"], 350, 100); PlaceHolder1.Controls.Add(new LiteralControl(" | ")); PlaceHolder1.Controls.Add(hl); // PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); } PlaceHolder1.Controls.Add(new LiteralControl("</h2><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">")); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); bool foundItems = false; if (!ctl.Custom) { tblControlsXItems cxi = new tblControlsXItems(); cxi.Where.ControlId.Value = controlId; cxi.Where.LanguageId.Value = Int32.Parse(Request["langId"]); cxi.Query.Load(); cxi.Sort = "SortOrder"; if (cxi.RowCount > 0) { cxi.Rewind(); do { admin_controls_ctlEditItem edit = (admin_controls_ctlEditItem)Page.LoadControl("~/admin/controls/ctlEditItem.ascx"); edit.LoadItem(cxi.ItemId); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); PlaceHolder1.Controls.Add(edit); PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); foundItems = true; } while (cxi.MoveNext()); } } else { //PlaceHolder1.Controls.Add(new LiteralControl("<tr><td style=\"padding:8px;\">")); //PlaceHolder1.Controls.Add(Page.LoadControl("~/App_Controls/" + ctl.CustomCmsLocation)); //PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); //foundItems = true; admin_controls_ctlEditItem edit = (admin_controls_ctlEditItem)Page.LoadControl("~/admin/controls/ctlEditItem.ascx"); edit.LoadCustomItem(ctl.CustomCmsLocation); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); PlaceHolder1.Controls.Add(edit); PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); foundItems = true; } if ((!foundItems) && ((int)UserContext.GetContextItemAsInt("userlevel") != 1)) { for (int x = PlaceHolder1.Controls.Count - 1; x >= start; x--) { PlaceHolder1.Controls.RemoveAt(x); } } else { PlaceHolder1.Controls.Add(new LiteralControl("</table><br>")); } }