public static bool HasContentPageContent(ContentPlaceHolder cph) { IDictionary templates = null; MasterPage master = cph.Page.Master; while (templates == null && master != null) { templates = (IDictionary)_contentTemplatesProp.GetValue(master, null); master = master.Master; } if (templates == null) return false; bool isSpecified = false; foreach (string key in templates.Keys) { if (key == cph.ID) { isSpecified = true; break; } } return isSpecified; }
protected override void Render(HtmlTextWriter output) { WebPage page = N2.Context.CurrentPage as WebPage; if (page == null) return; ILanguage pageLanguage = page.GetLanguage(); MetaTag languageMetaTag = (pageLanguage != null) ? new MetaTag() { HttpEquiv = "Content-Language", Content = pageLanguage.LanguageCode } : null; IEnumerable<MetaTag> tags = (new MetaTag[]{ new MetaTag() { TagName = "keywords", Content = page.MetaKeywords }, new MetaTag() { TagName = "description", Content = page.MetaDescription } }) .Union( page.MetaTagItems); ContentPlaceHolder container = new ContentPlaceHolder(); foreach (MetaTag tag in tags) tag.AddTo(container); if (languageMetaTag != null) languageMetaTag.AddTo(container); container.RenderControl(output); }
private void InitReloadParentPageControl() { if (!Page.ClientScript.IsClientScriptIncludeRegistered("ReloadParentPageScript")) { Page.ClientScript.RegisterClientScriptInclude("ReloadParentPageScript", ResolveClientUrl("~/js/reloadParentPage.js")); } Button btnReloadParentPage = new Button(); btnReloadParentPage.ID = "btnReloadParentPage"; btnReloadParentPage.ClientIDMode = System.Web.UI.ClientIDMode.Static; btnReloadParentPage.Height = Unit.Pixel(1); btnReloadParentPage.Width = Unit.Pixel(1); btnReloadParentPage.Style.Add(HtmlTextWriterStyle.Visibility, "hidden"); btnReloadParentPage.Click += new EventHandler(btnReloadParentPage_Click); System.Web.UI.WebControls.ContentPlaceHolder contentPlaceHolder = this.ContentPlaceHolder; if (contentPlaceHolder != null) { if (!contentPlaceHolder.Controls.Contains(btnReloadParentPage)) { contentPlaceHolder.Controls.Add(btnReloadParentPage); } } }
/// <summary> /// Wypełnienie kontrolek treścią. /// Podsumowanie towarów w koszyku. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { User_B.Text = User.Instance.Name + " " + User.Instance.Surname; content = (ContentPlaceHolder)this.FindControl("ProduktyKoszyk"); var i = 0; var suma = 0.0; var part = 0.0; foreach (var pr in User.Instance.Basket) { var co = new Label(); co.ID = "co_" + i.ToString(); co.Width = 300; content.Controls.Add(co); var nazwa = new Label(); nazwa.ID = "n_" + i.ToString(); nazwa.Text = pr.Key.Name; nazwa.Width = 600; content.Controls.Add(nazwa); var cenaPoj = new Label(); cenaPoj.ID = "cp_" + i.ToString(); cenaPoj.Text = pr.Key.Price.ToString() + " PLN"; cenaPoj.Width = 100; content.Controls.Add(cenaPoj); var ex = new Label(); ex.ID = "x_" + i.ToString(); ex.Text = " x "; ex.Width = 50; content.Controls.Add(ex); var ilosc = new Label(); ilosc.ID = "i_" + i.ToString(); ilosc.Text = pr.Value.ToString(); ilosc.Enabled = true; ilosc.Width = 50; content.Controls.Add(ilosc); var eq = new Label(); eq.ID = "e_" + i.ToString(); eq.Text = " = "; eq.Width = 50; content.Controls.Add(eq); var cenaAll = new Label(); cenaAll.ID = "ca_" + i.ToString(); part = pr.Key.Price * pr.Value; cenaAll.Text = String.Format("{0:0.##}", part) + " PLN"; cenaAll.Width = 200; content.Controls.Add(cenaAll); content.Controls.Add(new LiteralControl("<p /><p />")); suma += part; i++; } Total_L.Text = String.Format("{0:0.##}", suma) + " PLN"; }
/// <summary> /// Wypełnianie strony treścią. /// Dynamiczne dodawanie elementów koszyka. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { User_B.Text = User.Instance.Name + " " + User.Instance.Surname; content = (ContentPlaceHolder)this.FindControl("ProduktyKoszyk"); foreach (var pr in User.Instance.Basket) { var co = new Label(); co.ID = "co_" + count.ToString(); co.Width = 300; content.Controls.Add(co); var nazwa = new Label(); nazwa.ID = "n_" + count.ToString(); nazwa.Text = pr.Key.Name; nazwa.Enabled = false; nazwa.Width = 600; content.Controls.Add(nazwa); var cenaPoj = new Label(); cenaPoj.ID = "cp_" + count.ToString(); cenaPoj.Text = pr.Key.Price.ToString() + " PLN"; cenaPoj.Enabled = false; cenaPoj.Width = 100; content.Controls.Add(cenaPoj); var ex = new Label(); ex.ID = "x_" + count.ToString(); ex.Text = " x "; ex.Width = 50; content.Controls.Add(ex); var ilosc = new TextBox(); ilosc.ID = "i_" + count.ToString(); ilosc.Text = pr.Value.ToString(); ilosc.TextMode = TextBoxMode.Number; ilosc.TextChanged += ChangedValue; ilosc.Enabled = true; ilosc.Width = 50; content.Controls.Add(ilosc); var usun = new Button(); usun.ID = "u_" + count.ToString(); usun.Text = "Usuń"; usun.Click += DeleteProduct; usun.Width = 100; usun.BackColor = Color.Red; usun.ForeColor = Color.White; content.Controls.Add(usun); content.Controls.Add(new LiteralControl("<p /><p />")); count++; } Dalej_B.Enabled = count != 0; }
// Initialize controls public override void InitShadow(System.Web.UI.WebControls.ContentPlaceHolder oContentPage) { #region begin lblSite = (Hidden)oContentPage.FindControl("lblSite"); lblBu = (Hidden)oContentPage.FindControl("lblBu"); lblBuilding = (Hidden)oContentPage.FindControl("lblBuilding"); txtFormNo = (TextField)oContentPage.FindControl("txtFormNo"); txtCustomer = (TextField)oContentPage.FindControl("txtCustomer"); txtDate = (TextField)oContentPage.FindControl("txtDate"); txtNotes = (TextArea)oContentPage.FindControl("txtNotes"); cmbPhase = (ComboBox)oContentPage.FindControl("cmbPhase"); cmbPlant = (ComboBox)oContentPage.FindControl("cmbPlant"); cbProductType = (ComboBox)oContentPage.FindControl("cbProductType"); txtModel = (TextField)oContentPage.FindControl("txtModel");; cmbLayout = (MultiCombo)oContentPage.FindControl("cmbLayout");; txtPM = (TextField)oContentPage.FindControl("txtPM"); txtRD = (TextField)oContentPage.FindControl("txtRD"); txtSales = (TextField)oContentPage.FindControl("txtSales"); txtNextStage_BeginDate = (DateField)oContentPage.FindControl("txtNextStage_BeginDate"); ConAttachment = (Container)oContentPage.FindControl("ConAttachment"); cmbPM = (ComboBox)oContentPage.FindControl("cmbPM"); cmbRD = (ComboBox)oContentPage.FindControl("cmbRD"); cmbSales = (ComboBox)oContentPage.FindControl("cmbSales"); txtPMExt = (NumberField)oContentPage.FindControl("txtPMExt"); txtRDExt = (NumberField)oContentPage.FindControl("txtRDExt"); txtSalesExt = (NumberField)oContentPage.FindControl("txtSalesExt"); pnlCountersign = (Panel)oContentPage.FindControl("pnlCountersign"); grdResult = (GridPanel)oContentPage.FindControl("grdResult"); btnDelete = (Button)oContentPage.FindControl("btnDelete"); cmbAttachmentType = (ComboBox)oContentPage.FindControl("cmbAttachmentType"); btnDelete = (Button)oContentPage.FindControl("btnDelete"); grdAttachment = (GridPanel)oContentPage.FindControl("grdAttachment"); pnlResult = (Panel)oContentPage.FindControl("pnlResult"); rgResult = (RadioGroup)oContentPage.FindControl("rgResult"); txtReslutOpinion = (TextArea)oContentPage.FindControl("txtReslutOpinion"); rdResultY = (Radio)oContentPage.FindControl("rdResultY"); rdResultN = (Radio)oContentPage.FindControl("rdResultN"); rdReulutCondition = (Radio)oContentPage.FindControl("rdReulutCondition"); #endregion }
public void HideControls(ContentPlaceHolder cnt, System.Web.UI.Page pg) { string pagename = HttpContext.Current.Request.Url.AbsolutePath.ToLower().Replace("/", "").Replace(".aspx", "").ToString(); string controllist = ""; switch (pagename) { case "show": { controllist = "pnlshow"; break; } case "personal": { controllist = "pnlpersonal"; break; } case "presenter": { controllist = "pnlpresenter"; break; } case "metro": { controllist = "pnlmetro"; break; } case "venue": { controllist = "pnlvenue"; break; } } Panel ctl = (Panel)cnt.FindControl(controllist); if (ctl != null) { ctl.Enabled = false; } //for (int i = 0; i < controllist.Split(',').Length; i++) //{ // //System.Web.UI.Control ctl =(System.Web.UI.Control) cnt.FindControl(controllist.Split(',')[i]); // Panel ctl = (Panel)cnt.FindControl(controllist.Split(',')[i]); // if (ctl != null) // { // ctl.Enabled = false; // } //} }
public static bool HasNonEmptyControls(ContentPlaceHolder cph) { if (cph.Controls.Count == 0) { return false; } else if (cph.Controls.Count == 1) { LiteralControl c = cph.Controls[0] as LiteralControl; if (string.IsNullOrEmpty(c.Text) || IsWhiteSpace(c.Text)) return false; } return true; }
protected void Page_Load(object sender, EventArgs e) { mcph = MenuContentPlaceHolder; if (IsUserLoggedIn()) { userLevel = GetUserLevel(); } if (!LiveDocs.backend.Pages.CheckAccess(userLevel, MainContentPlaceHolder.Page)) { MainContentPlaceHolder.Controls.Add(new Label() { Text = "You do not have the neccesary accesslevel for this page. Forgot to log in?" }); } }
protected void Page_Load(object sender, EventArgs e) { DirectoryInfo di = new DirectoryInfo("C:\\Projetos\\Fototeca\\Web\\BancoImagens\\BI_UI\\img\\imgbnk"); FileSystemInfo[] fsa; Image img; HyperLink lnk; ContentPlaceHolder cph = new ContentPlaceHolder(); Table tbl = new Table(); TableRow row = new TableRow(); TableCell cell; int cntCells = 0; cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); fsa = di.GetFileSystemInfos("*.jpg"); foreach (FileSystemInfo fsi in fsa) { lnk = new HyperLink(); lnk.NavigateUrl = fsi.FullName; lnk.Attributes.Add("rel", "lightbox[roadtrip]"); img = new Image(); img.ImageUrl = "ThumbImage.aspx?img=" + fsi.FullName; lnk.Controls.Add(img); cell = new TableCell(); cell.Controls.Add(lnk); row.Cells.Add(cell); cntCells += 1; if (cntCells == 3) { tbl.Rows.Add(row); cntCells = 0; row = new TableRow(); } } tbl.Rows.Add(row); cph.Controls.Add(tbl); }
// Initialize controls public override void InitShadow(System.Web.UI.WebControls.ContentPlaceHolder oContentPage) { #region Begin vMain = (Panel)oContentPage.FindControl("vMain"); pnlMain = (Panel)oContentPage.FindControl("pnlMain"); frmUserInfo = (Panel)oContentPage.FindControl("frmUserInfo"); frmApplyInfo = (Panel)oContentPage.FindControl("frmApplyInfo"); //基本資料 txtLogonID = (TextField)oContentPage.FindControl("txtLogonID"); txtName = (TextField)oContentPage.FindControl("txtName"); txtPlant = (TextField)oContentPage.FindControl("txtPlant"); txtDept = (TextField)oContentPage.FindControl("txtDept"); txtEMail = (TextField)oContentPage.FindControl("txtEMail"); txtExtNO = (TextField)oContentPage.FindControl("txtExtNO"); //單據資料 txtRDocNo = (TextField)oContentPage.FindControl("txtRDocNo"); btnLink = (Button)oContentPage.FindControl("btnLink"); txtDocNo = (TextField)oContentPage.FindControl("txtDocNo"); txtCostCenter = (TextField)oContentPage.FindControl("txtCostCenter"); txtDepartment = (TextField)oContentPage.FindControl("txtDepartment"); txtApplication = (TextField)oContentPage.FindControl("txtApplication"); txtMaterial = (ComboBox)oContentPage.FindControl("txtMaterial"); txtReturnQuantity = (TextField)oContentPage.FindControl("txtReturnQuantity"); txtReason = (ComboBox)oContentPage.FindControl("txtReason"); txtRemark = (TextArea)oContentPage.FindControl("txtRemark"); txtReturn = (TextField)oContentPage.FindControl("txtReturn"); txtIADocNo = (TextField)oContentPage.FindControl("txtIADocNo"); txtI6DocNo = (TextField)oContentPage.FindControl("txtI6DocNo"); txtZEILE = (TextField)oContentPage.FindControl("txtZEILE"); txtAmount = (TextField)oContentPage.FindControl("txtAmount"); //SOURCE DATA txtHead = (TextField)oContentPage.FindControl("txtHead"); txtDOA = (TextField)oContentPage.FindControl("txtDOA"); txtDetail = (TextField)oContentPage.FindControl("txtDetail"); txtWERKS = (TextField)oContentPage.FindControl("txtWERKS"); txtAPTYP = (TextField)oContentPage.FindControl("txtAPTYP"); #endregion }
public void usercontrollist(string ucname, ContentPlaceHolder uc_cnt, string uc_list) { string[] arr = uc_list.Split(','); System.Web.UI.Control uc = (System.Web.UI.Control)uc_cnt.FindControl(ucname); for (int i = 0; i < arr.Length; i++) { uc.FindControl(arr[i]).Visible = false; } }
public static Control CreateDoctypes(string part, ref IEnumerable<Control> current) { if (part == null) return null; using (ContentPlaceHolder root = new ContentPlaceHolder()) { string second = part.Substring(part.IndexOf(':') + 1); root.Controls.Add(new LiteralControl(GetDoctype(second))); using (HtmlControl html = HtmlElementFactory.Create("html")) { if (!second.StartsWith("x", StringComparison.Ordinal)) { html.Attributes["lang"] = "en"; } else { html.Attributes["xmlns"] = "http://www.w3.org/1999/xhtml"; html.Attributes["xml:lang"] = "en"; } root.Controls.Add(html); using (HtmlControl head = HtmlElementFactory.Create("head")) using (HtmlControl title = HtmlElementFactory.Create("title")) using (HtmlControl meta = ShortcutHelper.Parse("meta:utf")) { head.Controls.Add(title); head.Controls.Add(meta); html.Controls.Add(head); } using (HtmlControl body = HtmlElementFactory.Create("body")) { html.Controls.Add(body); current = new Control[] { body }; } return root; } } }
private void SetupMasterPage() { // default to not allow page override so the non content system pages // will still use the site default skin // even if the default content page has an alternate skin // allowSkinOverride is overridden in Default.aspx.cs for content system // pages EnsureSiteSettings(); if ( (siteSettings != null) && (siteSettings.SiteGuid != Guid.Empty) ) { string skinName = SiteUtils.GetSkinName(allowSkinOverride, this); if (setMasterInBasePage) { //SiteUtils.SetMasterPage(this, siteSettings, allowSkinOverride); MasterPageFile = SiteUtils.GetMasterPage(this, skinName, siteSettings, allowSkinOverride); MasterPageFile = "~/App_MasterPages/SMT.Master"; } SetupTheme(skinName); } if (!string.IsNullOrEmpty(MasterPageFile)) { leftPane = (ContentPlaceHolder)Master.FindControl("leftContent"); centerPane = (ContentPlaceHolder)Master.FindControl("mainContent"); rightPane = (ContentPlaceHolder)Master.FindControl("rightContent"); editPane = (ContentPlaceHolder)Master.FindControl("pageEditContent"); altPane1 = (ContentPlaceHolder)Master.FindControl("altContent1"); altPane2 = (ContentPlaceHolder)Master.FindControl("altContent2"); } }
public static void CreateDynamicTable(ContentPlaceHolder ContentPlaceHolder1,string customerId) { var context = new int422Final.Private.Models.exam_Entities(); //if the model ID does not exist, this statement throws an exception var theVehicle = context.v_Customer_Vehicle.Where(i => i.customer_id == customerId).OrderBy(n => n.model_id); //ContentPlaceHolder1.Controls.Clear(); // Create a Table and set its properties Table tbl = new Table(); // Add the table to the placeholder control ContentPlaceHolder1.Controls.Add(tbl); //add first table row TableRow tr = new TableRow(); TableCell tc = new TableCell(); TextBox txtBox = new TextBox(); txtBox.Text = "Model ID"; tc.Controls.Add(txtBox); tr.Cells.Add(tc); TableCell tc1 = new TableCell(); TextBox txtBox1 = new TextBox(); txtBox1.Text = "Color"; tc1.Controls.Add(txtBox1); tr.Cells.Add(tc1); TableCell tc2 = new TableCell(); TextBox txtBox2 = new TextBox(); txtBox2.Text = "Transmission"; tc2.Controls.Add(txtBox2); tr.Cells.Add(tc2); TableCell tc3 = new TableCell(); TextBox txtBox3 = new TextBox(); txtBox3.Text = "Insured"; tc3.Controls.Add(txtBox3); tr.Cells.Add(tc3); tbl.Rows.Add(tr); foreach (var item in theVehicle) { TableRow tr1 = new TableRow(); TableCell tc4 = new TableCell(); TextBox txtBox4 = new TextBox(); txtBox4.Text = item.model_id; // Add the control to the TableCell tc4.Controls.Add(txtBox4); // Add the TableCell to the TableRow tr1.Cells.Add(tc4); TableCell tc5 = new TableCell(); TextBox txtBox5 = new TextBox(); txtBox5.Text = item.color; // Add the control to the TableCell tc5.Controls.Add(txtBox5); // Add the TableCell to the TableRow tr1.Cells.Add(tc5); TableCell tc6 = new TableCell(); TextBox txtBox6 = new TextBox(); txtBox6.Text = item.trans; // Add the control to the TableCell tc6.Controls.Add(txtBox6); // Add the TableCell to the TableRow tr1.Cells.Add(tc6); TableCell tc7 = new TableCell(); TextBox txtBox7 = new TextBox(); if (item.insured == true){ txtBox7.Text = "Yes"; } if (item.insured == false){ txtBox7.Text = "No"; } // Add the control to the TableCell tc7.Controls.Add(txtBox7); // Add the TableCell to the TableRow tr1.Cells.Add(tc7); // Add the TableRow to the Table tbl.Rows.Add(tr1); } context.SaveChanges(); }
private void HandleOpenTag(Stack<Control> container, HtmlChunk chunk, StringBuilder currentLiteralText) { if (chunk.TagName.Equals("title", StringComparison.OrdinalIgnoreCase)) { this.AddIfNotEmpty(currentLiteralText.ToString(), container.Peek()); var title = new HtmlTitle(); container.Peek().Controls.Add(title); container.Push(title); } else if (chunk.TagName.Equals("head", StringComparison.OrdinalIgnoreCase)) { this.AddIfNotEmpty(currentLiteralText.ToString(), container.Peek()); currentLiteralText.Clear(); var head = new HtmlHead(); container.Peek().Controls.Add(head); container.Push(head); } else if (chunk.TagName.Equals("asp:ContentPlaceHolder", StringComparison.OrdinalIgnoreCase)) { this.AddIfNotEmpty(currentLiteralText.ToString(), container.Peek()); currentLiteralText.Clear(); if (chunk.HasAttribute("ID")) { var id = chunk.AttributesMap["ID"] as string; var placeHolder = new ContentPlaceHolder() { ID = id }; container.Peek().Controls.Add(placeHolder); this.AddContentPlaceHolder(id); this.InstantiateControls(placeHolder); } } else if (chunk.TagName.Equals("form", StringComparison.OrdinalIgnoreCase) && chunk.HasAttribute("runat")) { this.AddIfNotEmpty(currentLiteralText.ToString(), container.Peek()); currentLiteralText.Clear(); var form = new HtmlForm(); if (chunk.HasAttribute("id")) form.ID = chunk.AttributesMap["id"] as string; else form.ID = "aspnetForm"; container.Peek().Controls.Add(form); container.Push(form); } else if (chunk.TagName.Equals(LayoutsHelpers.SectionTag, StringComparison.OrdinalIgnoreCase)) { this.AddIfNotEmpty(currentLiteralText.ToString(), container.Peek()); currentLiteralText.Clear(); var sectionRenderer = new SectionRenderer(); if (chunk.HasAttribute("name")) { sectionRenderer.Name = chunk.AttributesMap["name"].ToString(); } container.Peek().Controls.Add(sectionRenderer); } else if (chunk.TagName == "%@") { //// Ignore } else { currentLiteralText.Append(chunk.Html); } }
public static bool HasContent(ContentPlaceHolder cph) { return HasNonEmptyControls(cph) || HasContentPageContent(cph); }
protected void tnUsrCont_Click(object sender, EventArgs e) { cph = this.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder; uc = this.LoadControl("Step1.ascx") as UserControl; uc.Attributes.Add("runat", "server"); cph.Controls.Add(uc); }
private void SetupMasterPage() { try { _contentRegion = (ContentPlaceHolder)this.Master.FindControl("cphContent"); } catch { _contentRegion = null; } }
protected void Page_Init(object sender, EventArgs e) { Body = (ContentPlaceHolder)this.Master.FindControl("MainContent"); }