protected override void CreateChildControls() { int added = 0; foreach (ContentItem page in Find.EnumerateParents(Find.CurrentPage, Find.ClosestLanguageRoot, true)) { IBreadcrumbAppearance appearance = page as IBreadcrumbAppearance; bool visible = appearance == null || appearance.VisibleInBreadcrumb; if (visible && page.IsPage) { ILink link = appearance == null ? (ILink)page : appearance; if (added > 0) { Controls.AddAt(0, new LiteralControl(SeparatorText)); PrependAnchor(link, null); } else { PrependAnchor(link, "current"); } ++added; } } if (added < VisibilityLevel) { this.Visible = false; } base.CreateChildControls(); }
protected override void OnPreRender(System.EventArgs e) { base.OnPreRender(e); if (!string.IsNullOrEmpty(Icon)) { var icon = new Literal { Text = string.Format("<i class=\"{0}\"></i> {1}", Icon, Text) }; Controls.AddAt(0, icon); } if (!Enabled) { Attributes["class"] += " disabled"; Attributes.Add("disabled", "disabled"); } if (Mode == ButtonMode.Primary) { Attributes["class"] += " btn-primary"; } else if (Mode == ButtonMode.Danger) { Attributes["class"] += " btn-danger"; } else { Attributes["class"] += " btn-default"; } Attributes["class"] += " btn"; }
/// <include file='doc\Form.uex' path='docs/doc[@for="Form.CreateDefaultTemplatedUI"]/*' /> public override void CreateDefaultTemplatedUI(bool doDataBind) { ITemplate headerTemplate = GetTemplate(Constants.HeaderTemplateTag); ITemplate footerTemplate = GetTemplate(Constants.FooterTemplateTag); ITemplate scriptTemplate = GetTemplate(Constants.ScriptTemplateTag); if (scriptTemplate != null) { _scriptContainer = new TemplateContainer(); // The scriptTemplate is not added to the controls tree, so no need to do // CheckedInstantiateTemplate to check for infinite recursion. scriptTemplate.InstantiateIn(_scriptContainer); _scriptContainer.EnablePagination = false; } if (headerTemplate != null) { _headerContainer = new TemplateContainer(); CheckedInstantiateTemplate(headerTemplate, _headerContainer, this); _headerContainer.EnablePagination = false; Controls.AddAt(0, _headerContainer); } if (footerTemplate != null) { _footerContainer = new TemplateContainer(); CheckedInstantiateTemplate(footerTemplate, _footerContainer, this); _footerContainer.EnablePagination = false; Controls.Add(_footerContainer); } // Do not call base.CreateDefaultTemplatedUI(), since we don't want // Forms to have ContentTemplates as Panels do. }
/// <summary> /// Load filter control according filterpath. /// </summary> private void LoadFilter() { if (mFilterControl == null) { if (FilterControlPath != null) { try { if (File.Exists(Server.MapPath(FilterControlPath))) { mFilterControl = (Page.LoadUserControl(FilterControlPath)) as CMSAbstractBaseFilterControl; if (mFilterControl != null) { mFilterControl.ID = "filterControl"; Controls.AddAt(0, mFilterControl); mFilterControl.FilterName = FilterName; if (Page != null) { mFilterControl.Page = Page; } } } } catch (Exception ex) { EventLogProvider.LogException("Filter control", "LOADFILTER", ex); } } } }
/// <summary> /// Creates a persistent child control, that will be automatically re-created during future server requests. /// </summary> /// <returns>The persistent control.</returns> /// <param name="id">ID of your control. If null, an automatic id will be created and assigned control.</param> /// <param name="index">Index of where to insert control. If -1, the control will be appended into Controls collection.</param> /// <typeparam name="T">The type of control you want to create.</typeparam> public T CreatePersistentControl <T> (string id = null, int index = -1) where T : Control, new() { // Then we must make sure we store our original controls, before we start adding new ones to the Controls collection. // Notice, this is only done the first time we create a new child control for a Container widget. MakeSureOriginalControlsAreStored(); // Creating a new control, and adding to the controls collection. // Notice, we must use our GetCreator<T> method, since it populates our "_creators" field, with a string being the type's FullName and // the ICreator implementation creating a new Widget of type T. // Otherwise, our "_creator" static Dictionary object, will not contain an entry for the given type, when we're about to re-create our // widget upon our next callback/postback to the server. var control = GetCreator <T> ().Create() as T; control.ID = string.IsNullOrEmpty(id) ? CreateUniqueId() : id; if (index == -1) { Controls.Add(control); } else { Controls.AddAt(index, control); } // Returning newly created control back to caller, such that he can set other properties and such for it. return(control); }
/// <summary> /// Adds the captcha if necessary. /// </summary> /// <param name="captcha">The captcha.</param> /// <param name="invisibleCaptchaValidator">The invisible captcha validator.</param> /// <param name="btnIndex">Index of the BTN.</param> protected void AddCaptchaIfNecessary(ref CaptchaControl captcha, ref InvisibleCaptcha invisibleCaptchaValidator, int btnIndex) { if (Config.CurrentBlog.CaptchaEnabled) { captcha = new CaptchaControl { ID = "captcha" }; Control preExisting = ControlHelper.FindControlRecursively(this, "captcha"); if (preExisting == null) // && !Config.CurrentBlog.FeedbackSpamServiceEnabled) Experimental code for improved UI. Will put back in later. - Phil Haack 10/09/2006 { Controls.AddAt(btnIndex, captcha); } } else { RemoveCaptcha(); } if (Config.Settings.InvisibleCaptchaEnabled) { invisibleCaptchaValidator = new InvisibleCaptcha { ErrorMessage = "Please enter the answer to the supplied question." }; Controls.AddAt(btnIndex, invisibleCaptchaValidator); } }
void CreateLink() { if (HyperLink == null) { HyperLink = new System.Web.UI.HtmlControls.HtmlAnchor(); Controls.AddAt(0, HyperLink); } HyperLink.Target = Target ?? ""; HyperLink.HRef = NavigateUrl ?? "#"; //HyperLink.InnerText = Text; var spanText = (HtmlGenericControl)HyperLink.Controls.Cast <Control>().FirstOrDefault(c => c is HtmlGenericControl && ((HtmlGenericControl)c).Attributes["class"].Contains("menuText")); if (spanText == null) { spanText = new HtmlGenericControl("SPAN"); spanText.Attributes["class"] = "menuText"; HyperLink.Controls.Add(spanText); } spanText.InnerHtml = text; if (!string.IsNullOrEmpty(iconCssClass)) { var span = (HtmlGenericControl)HyperLink.Controls.Cast <Control>().FirstOrDefault(c => c is HtmlGenericControl && ((HtmlGenericControl)c).Attributes["class"].Contains("iconSpan")); if (span == null) { span = new HtmlGenericControl("SPAN"); span.Attributes["class"] = "iconSpan " + iconCssClass; HyperLink.Controls.AddAt(0, span); } } }
protected override void InitializeControls() { base.InitializeControls(); Controls.AddAt(0, CreateHtmlMainPage()); SetControlsDefInheritance(UId); InitializeLocalizableValues(); }
/// <summary> /// Load filter control according filterpath. /// </summary> private void LoadFilter() { if (mFilterControl == null) { if (FilterControlPath != null) { try { mFilterControl = (Page.LoadUserControl(FilterControlPath)) as CMSAbstractBaseFilterControl; if (mFilterControl != null) { mFilterControl.ID = "filterControl"; Controls.AddAt(0, mFilterControl); mFilterControl.FilterName = FilterName; if (Page != null) { mFilterControl.Page = Page; } } } catch (Exception ex) { EventLogProvider.LogException("Filter control", "LOADFILTER", ex, loggingPolicy: LoggingPolicy.ONLY_ONCE); } } } }
private void AddThankYouMessage() { Control placeHolder = new PlaceHolder(); ThankYouTemplate.InstantiateIn(placeHolder); Controls.AddAt(0, placeHolder); }
protected void AddDisplayable() { if (Site != null && Site.DesignMode) { return; } if (Displayable != null) { displayer = Displayable.AddTo(CurrentItem, PropertyName, this); if (displayer != null) { if (HeaderTemplate != null) { Control header = new SimpleTemplateContainer(); Controls.AddAt(0, header); HeaderTemplate.InstantiateIn(header); } if (FooterTemplate != null) { Control footer = new SimpleTemplateContainer(); Controls.Add(footer); FooterTemplate.InstantiateIn(footer); } } } }
private SiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node) { SiteMapNodeItem item = new SiteMapNodeItem(itemIndex, itemType); int index = (PathDirection == PathDirection.CurrentToRoot ? 0 : -1); SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item); //Add sitemap nodes so that they are accessible during events. item.SiteMapNode = node; InitializeItem(item); // Notify items OnItemCreated(e); // Add items based on PathDirection. Controls.AddAt(index, item); // Databind. item.DataBind(); // Notify items. OnItemDataBound(e); item.SiteMapNode = null; // SiteMapNodeItem is dynamically created each time, don't track viewstate. item.EnableViewState = false; return(item); }
private void RenderTitlePorletInDiv() { // Create div portlet header PSCPanel divHeader = new PSCPanel(); divHeader.CssClass = "psc-divPortlet-Header"; Controls.AddAt(0, divHeader); //Title Porlet System.Web.UI.WebControls.Literal lblTitle = new System.Web.UI.WebControls.Literal(); lblTitle.Text = string.Format("<span>{0}</span>", Portlet.PortletInstance.Portlet.Name); divHeader.Controls.Add(lblTitle); //Button Edit LiteralControl btnEdit = new LiteralControl(); btnEdit.Text = string.Format("<img src='{0}' onclick=\"{1}\" title='Hiệu chỉnh Dữ liệu' class='{2}' alt='{3}'/>", "/Systems/Engine/Images/PortletEditData.png", string.Format("PortletEditData('{0}');", Portlet.PortletInstance.Id), "ButtonImage", "Edit Portlet"); divHeader.Controls.Add(btnEdit); //Button giao dien LiteralControl btnEditApperance = new LiteralControl(); btnEditApperance.Text = string.Format("<img src='{0}' onclick=\"{1}\" title='Hiệu chỉnh CSS' class='{2}' alt='{3}'/>", "/Systems/Engine/Images/PortletEditApperance.png", string.Format("PortletEditCSS('{0}');", Portlet.PortletInstance.Id), "ButtonImage", "Edit Portlet CSS"); divHeader.Controls.Add(btnEditApperance); // Button Delete LiteralControl btnDelete = new LiteralControl(); btnDelete.Text = string.Format("<img src='{0}' onclick=\"{1}\" title='Xóa Porlet' class='{2}' alt='{3}'/>", "/Systems/Engine/Images/PortletDelete.png", string.Format("PortletRemove('{0}','{1}');", Portlet.PortletInstance.Id, Portlet.PortletInstance.Name), "ButtonImage", "Remove Portlet"); divHeader.Controls.Add(btnDelete); }
protected void нопка_ќ _Click(object sender, EventArgs e) { try { ќтчетнऑормаƒанных отчетнऑорма = ѕолучитьќтчетную‘орму(); if (отчетнऑорма != null) { if (“аблица_элементы.SelectedIndexes.Count > 0) { int index = int.Parse(“аблица_элементы.SelectedIndexes[0]); јвтосохранениеƒанныхќтчетной‘ормы.јвтосохраненный‘айл автосохранение = (јвтосохранениеƒанныхќтчетной‘ормы.јвтосохраненный‘айл)“аблица_элементы.ѕолучить«начение»сточника«аписей(index); if (автосохранение != null) { отчетнऑорма.ƒанные.ќчиститьƒанные(); отчетнऑорма.ƒанные.«агрузить»з‘айла(автосохранение.ѕолныйѕуть‘айла); } Controls.AddAt(3, new LiteralControl("<script type=\"text/javascript\">CloseAndRebindSheet();</script>")); } else { Controls.AddAt(3, new LiteralControl("<script type=\"text/javascript\">alert('Ќеобходимо выбрать архив дл¤ восстановлени¤!');</script>")); } } } catch { Controls.AddAt(3, new LiteralControl("<script type=\"text/javascript\">alert('Ќе удалось восстановить архив!');</script>")); } }
private void SwapWithLabel(TextBox textBox) { int index = Controls.IndexOf(textBox); Controls.RemoveAt(index); Controls.AddAt(index, new LiteralControl(textBox.Text)); textBox.Visible = true; }
/// <summary> /// Render status information /// </summary> /// <param name="output"></param> protected override void Render(HtmlTextWriter output) { //add the status div to the top of the control Controls.AddAt(0, m_divStatus); //render the control base.RenderChildren(output); }
private void AddControl(int index) { var div = new HtmlGenericControl("div"); var textBox = new TextBox(); textBox.ID = "tb" + index; div.Controls.Add(textBox); Controls.AddAt(index, div); }
private void AddDescElement() { string desc = Description; if (!string.IsNullOrEmpty(desc)) { Controls.AddAt(0, new LiteralControl(string.Format("<desc>{0}</desc>", desc))); } }
protected override void CreateChildControls() { if (!string.IsNullOrEmpty(Label)) { Controls.AddAt(0, new Label { Text = Label, CssClass = "editorLabel" }); } foreach (ContentItem item in GetItems()) { CreateItemEditor(item); } itemEditorsContainer.Attributes["class"] = "item-editor-list-items items-count-" + itemEditorsContainer.Controls.Count; var allowedDefinitions = Parts.GetAllowedDefinitions(ParentItem, ZoneName, Page.User); allowedDefinitions = allowedDefinitions.Where(d => MinimumType.IsAssignableFrom(d.ItemType)); allowedDefinitions = allowedDefinitions.WhereAuthorized(Engine.SecurityManager, Engine.RequestContext.User, ParentItem); var allowedChildren = allowedDefinitions.SelectMany(d => Parts.GetTemplates(ParentItem, d)) .WhereAllowed(ParentItem, ZoneName, Engine.RequestContext.User, Engine.Definitions, Engine.SecurityManager) .ToList(); if (AllowedTemplateKeys != null) { allowedChildren = allowedChildren.Where(td => AllowedTemplateKeys.Contains(td.Name)).ToList(); } if (allowedChildren.Count == 0) { var alert = CreateControl(addPanel, "div", "alert"); alert.InnerHtml = "Cannot add any parts due to zone/user/type restrictions"; } else if (allowedChildren.Count == 1) { var btn = CreateButton(addPanel, allowedChildren[0]); btn.CssClass = "btn"; } else { var btnGroup = CreateControl(addPanel, "div", "btn-group"); var toggle = CreateControl(btnGroup, "a", "btn dropdown-toggle"); toggle.Attributes["data-toggle"] = "dropdown"; toggle.Attributes["href"] = "#"; toggle.InnerHtml = "<b class='fa fa-plus-circle'></b> " + (Utility.GetLocalResourceString("Add") ?? "Add") + " <b class='caret'></b>"; var dropdownMenu = CreateControl(btnGroup, "ul", "dropdown-menu"); foreach (var template in allowedChildren) { var li = CreateControl(dropdownMenu, "li", ""); CreateButton(li, template); } } base.CreateChildControls(); }
/// <summary> /// Overrides Microsoft's Event Handler. Recomended in official documentation for manipulations of the display. /// </summary> protected override void PrepareControlHierarchy() { DoRowSpanMerges(); FormatCellValues(); base.PrepareControlHierarchy(); NoDataMessagePlaceHolder.Controls.Add(NoDataMessage); Controls.AddAt(0, NoDataMessagePlaceHolder); }
private void CreateBreadCrumbWrapper() { _breadParent.ID = "breadParent"; _breadParent.CssClass = "bread-crumb-parent"; Controls.AddAt(0, _breadParent); _bread.ID = "bread"; _bread.CssClass = "bread-crumb"; ActualBreadCrumbParent.Controls.Add(_bread); }
protected override void CreateChildControls() { // Creating top wrapper _topPanel = new Panel(); _topPanel.ID = "top"; _topPanel.CssClass = "tab-header"; CreateChildTabViews(); Controls.AddAt(0, _topPanel); }
/// <include file='doc\Panel.uex' path='docs/doc[@for="Panel.CreateDefaultTemplatedUI"]/*' /> public override void CreateDefaultTemplatedUI(bool doDataBind) { ITemplate contentTemplate = GetTemplate(Constants.ContentTemplateTag); if (contentTemplate != null) { _deviceSpecificContents = new TemplateContainer(); CheckedInstantiateTemplate(contentTemplate, _deviceSpecificContents, this); Controls.AddAt(0, _deviceSpecificContents); } }
private void RenderTitlePorletInTable() { System.Web.UI.WebControls.Table tblTop = new System.Web.UI.WebControls.Table(); tblTop.CellPadding = 0; tblTop.CellSpacing = 0; System.Web.UI.WebControls.TableRow rTop = new System.Web.UI.WebControls.TableRow(); tblTop.Rows.Add(rTop); System.Web.UI.WebControls.TableCell cLeft = new System.Web.UI.WebControls.TableCell(); cLeft.Width = System.Web.UI.WebControls.Unit.Percentage(100); cLeft.CssClass = "TitlePortlet"; rTop.Cells.Add(cLeft); System.Web.UI.WebControls.TableCell cRight = new System.Web.UI.WebControls.TableCell(); rTop.Cells.Add(cRight); cRight.Width = System.Web.UI.WebControls.Unit.Pixel(50); cRight.CssClass = "PanelTitlePortlet"; System.Web.UI.WebControls.Panel pnTitle = new System.Web.UI.WebControls.Panel(); pnTitle.Width = System.Web.UI.WebControls.Unit.Percentage(100); System.Web.UI.WebControls.Label lblPortletInfo = new System.Web.UI.WebControls.Label(); lblPortletInfo.Text = string.Format("{0}{1}", Portlet.PortletInstance.Portlet.Name, Portlet.PortletInstance.Name != string.Empty ? "-" + Portlet.PortletInstance.Name : string.Empty); pnTitle.Controls.Add(lblPortletInfo); System.Web.UI.WebControls.Panel pnControlPortlet = new System.Web.UI.WebControls.Panel(); pnControlPortlet.Width = System.Web.UI.WebControls.Unit.Pixel(50); LiteralControl btnDelete = new LiteralControl(); btnDelete.Text = string.Format("<img src='{0}' onclick=\"{1}\" class='{2}' alt='{3}'/>", "/Systems/Engine/Images/PortletDelete.png", string.Format("PortletRemove('{0}','{1}');", Portlet.PortletInstance.Id, Portlet.PortletInstance.Name), "ButtonImage", "Remove Portlet"); LiteralControl btnEdit = new LiteralControl(); btnEdit.Text = string.Format("<img src='{0}' onclick=\"{1}\" class='{2}' alt='{3}'/>", "/Systems/Engine/Images/PortletEditData.png", string.Format("PortletEditData('{0}');", Portlet.PortletInstance.Id), "ButtonImage", "Edit Portlet"); LiteralControl btnEditApperance = new LiteralControl(); btnEditApperance.Text = string.Format("<img src='{0}' onclick=\"{1}\" class='{2}' alt='{3}'/>", "/Systems/Engine/Images/PortletEditApperance.png", string.Format("PortletEditCSS('{0}');", Portlet.PortletInstance.Id), "ButtonImage", "Edit Portlet CSS"); if (Portlet.PortletInstance.Portlet.EditURL.Trim() != string.Empty) { pnControlPortlet.Controls.Add(btnEdit); } pnControlPortlet.Controls.Add(btnEditApperance); pnControlPortlet.Controls.Add(btnDelete); _pnTop.ID = string.Format("{0}", "Title"); cLeft.Controls.Add(pnTitle); cRight.Controls.Add(pnControlPortlet); _pnTop.Controls.Add(tblTop); Controls.AddAt(0, _pnTop); }
private void CreateUnits() { CreateUnits(lightTable, "battle_lightAvailable", "light", "battle_lightUnitType"); CreateUnits(mediumTable, "battle_mediumAvailable", "medium", "battle_mediumUnitType"); CreateUnits(heavyTable, "battle_heavyAvailable", "heavy", "battle_heavyUnitType"); CreateUnits(animalsTable, "battle_animalsAvailable", "animal", "battle_animalType"); Controls.AddAt(0, lightTable); Controls.AddAt(1, mediumTable); Controls.AddAt(2, heavyTable); Controls.AddAt(3, animalsTable); }
protected override void OnInit(EventArgs e) { //double check for script-manager, if one doesn't exist, //then create one and add it to the page if (ScriptManager.GetCurrent(this.Page) == null) { ScriptManager sManager = new ScriptManager(); sManager.ID = "sManager_" + DateTime.Now.Ticks; Controls.AddAt(0, sManager); } base.OnInit(e); }
protected void RowAddDown(string tableId) { var nav = new EnumerableNavigation <Table, string>(Controls.Filter <Table>(), tableId, t => t.ID); if (nav.Current != null) { Table table = GetDataItemControl(null); Controls.AddAt(Controls.IndexOf(nav.Current) + 1, table); Sitecore.Context.ClientPage.ClientResponse.Insert(tableId, "afterEnd", table); } ClientResponseReturnValue(true); }
protected override void OnPreRender(EventArgs e) { Node n = (Node)Context.Items["currentNode"]; if (ShowTemplate) { Controls.AddAt(0, LoadControl(n.Template.HeaderFile)); } base.OnPreRender(e); if (ShowTemplate) { Controls.Add(LoadControl(n.Template.FooterFile)); } }
protected void RowFirst(string tableId) { var nav = new EnumerableNavigation <Table, string>(Controls.Filter <Table>(), tableId, t => t.ID); if (nav.Current != null && nav.Current != nav.First) { Controls.Remove(nav.Current); Controls.AddAt(0, nav.Current); Sitecore.Context.ClientPage.ClientResponse.Remove(tableId); Sitecore.Context.ClientPage.ClientResponse.Insert(nav.First.ID, "beforeBegin", nav.Current); } ClientResponseReturnValue(true); }
protected void нопка_ќ _Click(object sender, EventArgs e) { try { ѕользователь текущийѕользователь = this.–едактируемыйќбъект as ѕользователь; Dictionary <object, object> овые«начени¤ = онтроль—в¤зывани¤.ѕолучить«начени¤—войств(this); string старыйѕароль = (string)овые«начени¤["—тарыйѕароль"]; ѕользователь пользователь = new ѕользователь(); пользователь.ѕароль = старыйѕароль; if (текущийѕользователь.ѕароль != пользователь.ѕароль) { throw new Exception("¬ы ввели неправильный текущий пароль!"); } string новыйѕароль = (string)овые«начени¤["Ќовыйѕароль"]; string новыйѕароль2 = (string)овые«начени¤["Ќовыйѕароль2"]; if (новыйѕароль != новыйѕароль2) { throw new Exception("«начени¤ в пол¤х ѕароль и ѕодтверждение парол¤ не совпадают."); } try { текущийѕользователь.ѕароль = новыйѕароль; текущийѕользователь.«аблокировать(); текущийѕользователь.—охранить(); текущийѕользователь.—н¤тьЅлокировку(); } catch { текущийѕользователь.ѕеречитатьќбъект(); throw; } ¬ыставл¤ть–азмерыќкна = false; Controls.AddAt(0, new LiteralControl("<script type=\"text/javascript\">alert('ѕрофиль успешно изменен!');Close();</script>")); return; } catch (Exception exc) { —ообщение.ѕоказать»сключительную—итуацию(this, "Ќе удалось сохранить профиль.", exc); } }