public static jquerybasic FindjQuery(Control control) { jquerybasic jquerybasic1 = null; if (control is Page) { Page thePage = (Page)control; foreach (Control c in thePage.Header.Controls) { if (c is jquerybasic) { jquerybasic1 = (jquerybasic)c; break; } else { jquerybasic1 = FindjQuery(c); if (jquerybasic1 != null) { break; } } } } else { foreach (Control c in control.Controls) { if (c is jquerybasic) { jquerybasic1 = (jquerybasic)c; break; } else { jquerybasic1 = FindjQuery(c); if (jquerybasic1 != null) { break; } } } } return jquerybasic1; }
/* * Adds a child control to this control. */ /// <devdoc> /// <para>Adds the specified <see cref='System.Web.UI.Control'/> object /// to the collection. The new control is logically added to the end of an ordinal /// index array.</para> /// </devdoc> public virtual void Add(Control child) { // Note: duplication of code with AddAt is deliberate for performance reasons. This is the more common form of the call. // Check arguments if (child == null) throw new ArgumentNullException("child"); if (_readOnlyErrorMsg != null) { throw new HttpException(SR.GetString(_readOnlyErrorMsg )); } // Make sure we have room if (_controls == null) { _controls = new Control[_defaultCapacity]; } else if (_size >= _controls.Length) { Control[] newArray = new Control[_controls.Length * _growthFactor ]; Array.Copy(_controls, newArray, _controls.Length); _controls = newArray; } // Add the control int index = _size; _controls[index] = child; _size++; _version++; // Notify Owner _owner.AddedControl(child, index); }
/// <summary> /// Reads new values entered by the user for the field /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues"></param> /// <returns></returns> public override string GetEditValue( Control control, Dictionary<string, ConfigurationValue> configurationValues ) { if ( control != null && control is ListControl ) return ( (ListControl)control ).SelectedValue; return null; }
public override void UpdateEditor(N2.ContentItem item, Control editor) { if (item == null) throw new ArgumentNullException("item", "item is null."); if (editor == null) throw new ArgumentNullException("editor", "editor is null."); ListBox lb = (ListBox)editor; string currentlySelectedItemsString = (string)item[this.Name] ?? string.Empty; if (!string.IsNullOrEmpty(currentlySelectedItemsString)) { string[] currentlySelectedItems = currentlySelectedItemsString.Split(ItemSeperator); if (currentlySelectedItems.Length > 0) { foreach (string currentItem in currentlySelectedItems) { ListItem listItem = lb.Items.FindByValue(currentItem); if (listItem != null) listItem.Selected = true; } } } }
private static void BuildFromDirectory(string baseDir, Control level) { foreach (string idxDir in Directory.GetDirectories(baseDir)) { string dir = idxDir.Replace(baseDir, ""); // Skipping .svn and similar directories... if (dir.IndexOf(".") == 0) { continue; } TreeNode n = new TreeNode {ID = level.ID + dir, Xtra = idxDir, Text = dir}; level.Controls.Add(n); string[] childDirectories = Directory.GetDirectories(idxDir); if (childDirectories.Length > 0) { // Skipping .svn and similar directories... if (childDirectories.Length == 1) { string tmpDir = childDirectories[0]; tmpDir = tmpDir.Substring(tmpDir.LastIndexOf("\\") + 1); if (tmpDir.IndexOf(".") == 0) { continue; } } TreeNodes children = new TreeNodes {ID = "ch" + n.ID}; n.Controls.Add(children); BuildFromDirectory(idxDir + "\\", children); } } }
public void LoadWidgets(IEnumerable<Widget> widgetModels, Control placeholder, TemplateControl page) { if (placeholder == null) { return; } if (page == null) { return; } if (widgetModels == null) { return; } var groups = widgetModels.OrderBy(x => x.RowNumber).ThenBy(x => x.ColumnNumber).GroupBy(x => new {x.RowNumber}); foreach (var group in groups) { foreach (Widget item in group) { using (MixERPWidgetBase widget = page.LoadControl(item.WidgetSource) as MixERPWidgetBase) { if (widget != null) { placeholder.Controls.Add(widget); widget.OnControlLoad(widget, new EventArgs()); } } } } }
void GetModulePanel(string Panel, string lang) { ModulesFrontPanelBSO _module = new ModulesFrontPanelBSO(); DataTable tb = _module.GetModulesFrontPanelbyPanel(Panel, lang); string _path = ResolveUrl("~/") + "Client/Modules/MainHome/"; Control objControl = new Control(); if (tb.Rows.Count > 0) { for (int i = 0; i < tb.Rows.Count; i++) { //if (tb.Rows[i]["ModulesFrontPanel_Panel"].Equals("Left") || tb.Rows[i]["ModulesFrontPanel_Panel"].Equals("Right")) // _path += "Client/Modules/Panel/"; //else // if (tb.Rows[i]["ModulesFrontPanel_Panel"].Equals("Main")) // _path += "Client/Modules/MainHome/"; objControl = (Control)this.LoadControl(_path + tb.Rows[i]["ModulesFrontPanel_Url"].ToString()); AreaMainPanel.Controls.Add(objControl); ControlParameter(objControl, tb.Rows[i]["ModulesFrontPanel_Title"].ToString(), tb.Rows[i]["ModulesFrontPanel_Icon"].ToString(), tb.Rows[i]["ModulesFrontPanel_Value"].ToString(), Convert.ToInt32(tb.Rows[i]["ModulesFrontPanel_Record"].ToString())); } } }
public GridViewTemplate(DataControlRowType type, string colNameFr, string colNameDt, Control con) { templateType = type; columnNameFriendly = colNameFr; columnNameData = colNameDt; control = con; }
public override Control AddTo(Control container, PluginContext context) { HtmlGenericControl hgc = new HtmlGenericControl("div"); hgc.Attributes["class"] = "separator"; container.Controls.Add(hgc); return hgc; }
protected override void CreateItems(Control container) { if (State.IsFlagSet(ControlPanelState.DragDrop) && (AllowExternalManipulation || CurrentItem == CurrentPage || Find.ClosestPage(CurrentItem) == CurrentPage)) { if (ZoneName.IndexOfAny(new[] {'.', ',', ' ', '\'', '"', '\t', '\r', '\n'}) >= 0) throw new N2Exception("Zone '" + ZoneName + "' contains illegal characters."); Panel zoneContainer = AddPanel(this, ZoneName + " dropZone"); if (CurrentItem.ID != 0 && !CurrentItem.VersionOf.HasValue) { zoneContainer.Attributes["data-id"] = CurrentItem.ID.ToString(); zoneContainer.Attributes[PartUtilities.PathAttribute] = CurrentItem.Path; } else { zoneContainer.Attributes[PartUtilities.PathAttribute] = Find.ClosestPage(CurrentItem).Path; zoneContainer.Attributes["data-versionKey"] = CurrentItem.GetVersionKey(); zoneContainer.Attributes["data-versionIndex"] = CurrentItem.VersionIndex.ToString(); } zoneContainer.Attributes[PartUtilities.ZoneAttribute] = ZoneName; zoneContainer.Attributes[PartUtilities.AllowedAttribute] = PartUtilities.GetAllowedNames(ZoneName, PartsAdapter.GetAllowedDefinitions(CurrentItem, ZoneName, Page.User)); zoneContainer.ToolTip = GetToolTip(GetDefinition(CurrentItem), ZoneName); base.CreateItems(zoneContainer); } else { base.CreateItems(this); } }
private Control GetWebValidateBox(Control ct) { if (ct is WebValidate) { return ct; } else if (ct.HasControls()) { foreach (Control ctchild in ct.Controls) { if (ctchild is WebValidate) { return ctchild; } else { GetWebValidateBox(ctchild); } } return null; } else { return null; } }
private static void TranslateControlText(Control control) { IEnumerable<IControlTranslator> translators = GetControlTranslators(control); foreach (IControlTranslator translator in translators) translator.Translate(); }
public override bool UpdateItem(ContentItem item, Control editor) { TextBox tb = (TextBox)editor; string[] rows = tb.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = item.Children.Count - 1; i >= 0; --i) { int index = Array.FindIndex(rows, delegate(string row) { return row == item.Children[i].Title; } ); if (index < 0) Context.Persister.Delete(item.Children[i]); } for (int i = 0; i < rows.Length; i++) { ContentItem child = FindChild(item, rows[i]); if (child == null) { child = new Option(); child.Title = rows[i]; child.AddTo(item); } child.SortOrder = i; editor.RegisterItemToSave(child); } return true; }
public void InstantiateIn(Control container) { Literal l = new Literal(); l.Text = "<div>"; l.DataBinding += new EventHandler(this.BindData); container.Controls.Add(l); }
private void CreateErrorLabel(Control container) { this.errorLabel = new HtmlGenericControl("div"); this.errorLabel.Attributes.Add("class", "big error"); container.Controls.Add(this.errorLabel); }
protected override Control AddEditor(Control container) { var editor = base.AddEditor(container); if (string.IsNullOrEmpty(Title)) AddHelp(container); return editor; }
protected override Control AddEditor(Control container) { TimeRange range = new TimeRange {ID = Name + NameEndRange, StartTitle = StartTitle, StartRequired = StartRequired}; container.Controls.Add(range); range.BetweenText = BetweenText; return range; }
public void LoadWidgets(IEnumerable<DefaultWidgetSetupView> widgetModels, Control placeholder, TemplateControl page) { if (placeholder == null) { return; } if (page == null) { return; } if (widgetModels == null) { return; } foreach (DefaultWidgetSetupView item in widgetModels.OrderBy(x => x.WidgetOrder)) { using (MixERPWidget widget = page.LoadControl(item.WidgetSource) as MixERPWidget) { if (widget != null) { placeholder.Controls.Add(widget); widget.OnControlLoad(widget, new EventArgs()); } } } }
public MailMessage CreateMailMessage(string recipients, IDictionary replacements, Control owner) { if (owner == null) { throw new ArgumentNullException("owner"); } string body = string.Empty; string bodyFileName = this.BodyFileName; if (!string.IsNullOrEmpty(bodyFileName)) { string path = bodyFileName; if (!UrlPath.IsAbsolutePhysicalPath(path)) { path = UrlPath.Combine(owner.AppRelativeTemplateSourceDirectory, path); } TextReader reader = new StreamReader(owner.OpenFile(path)); try { body = reader.ReadToEnd(); } finally { reader.Close(); } } return this.CreateMailMessage(recipients, replacements, body, owner); }
public void addProperty(string Caption, Control C) { /* tr = new TableRow(); td = new TableCell(); td.Text = Caption; td.Attributes.Add("width", "15%"); td.Attributes.Add("valign", "top"); td.Attributes.Add("class", "propertyHeader"); tr.Cells.Add(td); td = new TableCell(); td.Attributes.Add("class", "propertyContent"); td.Controls.Add(C); tr.Cells.Add(td); tbl.Rows.Add(tr); if (!this.Controls.Contains(tbl)) { this.Controls.Add(tbl); }*/ PropertyPanel pp = new PropertyPanel(); pp.Controls.Add(C); pp.Text = Caption; this.Controls.Add(pp); }
internal RegisteredExpandoAttribute (Control control, string controlId, string name, string value, bool encode) { _control = control; _name = name; _value = value; _controlId = controlId; _encode = encode; }
public override Control AddTo(ContentItem item, string detailName, Control container) { Control displayer = (Control)Activator.CreateInstance(ControlType); Utility.SetProperty(displayer, ControlPropertyName, item[detailName]); container.Controls.Add(displayer); return displayer; }
public override Control AddTo(Control container, PluginContext context) { var selector = context.Engine.Resolve<LanguageGatewaySelector>(); if (!selector.Enabled || selector.LanguagesPerSite /*avoid showing options that might not be relevant */) return null; ILanguageGateway gateway = selector.GetAllLanguages(); HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes["class"] = "languages"; container.Controls.Add(div); base.AddTo(div, context); foreach (ILanguage language in gateway.GetAvailableLanguages()) { Url url = Engine.ManagementPaths.ResolveResourceUrl("{ManagementUrl}/Content/Globalization/Translate.aspx"); url = url.AppendQuery("language", language.LanguageCode); url = url.AppendQuery(SelectionUtility.SelectedQueryKey + "={selected}"); HyperLink h = new HyperLink(); h.ID = language.LanguageCode.Replace('-', '_').Replace(' ', '_'); h.Target = Targets.Preview; h.NavigateUrl = context.Rebase(context.Format(url, true)); h.CssClass = "templatedurl language"; h.ToolTip = language.LanguageTitle; h.Text = string.Format("<img src='{0}' alt=''/>", Url.ToAbsolute(language.FlagUrl)); h.Attributes["data-url-template"] = context.Rebase(url); div.Controls.Add(h); } return div; }
protected void AddEditable() { editable = GetEditable(CurrentItem); editor = editable.AddTo(this); if (!Page.IsPostBack) editable.UpdateEditor(CurrentItem, editor); }
public static bool ControlWasPostedBack(Page page, Control target) { bool result = false; string ctlName = page.Request.Params.Get("__EVENTTARGET"); if (ctlName != null && ctlName != string.Empty) { if (ctlName.Contains(target.ID)) { result = true; } } else { foreach (string ctl in page.Request.Form) { if (ctl.Contains(target.ID)) { result = true; break; } } } return result; }
/// <summary> /// Returns the field's current value(s) /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">Information about the value</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param> /// <returns></returns> public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed ) { string videoUrl = value; if ( !string.IsNullOrEmpty( videoUrl ) ) { if ( condensed ) { return videoUrl; } else { string htmlFormat = @" <audio src='{0}' class='img img-responsive js-media-audio' controls > </audio> <script> Rock.controls.mediaPlayer.initialize(); </script> "; var html = string.Format( htmlFormat, videoUrl ); return html; } } // value was null return null; }
protected override Label AddLabel(Control container) { if (string.IsNullOrEmpty(Title)) return null; return base.AddLabel(container); }
public override Control AddTo(Control container, PluginContext context) { var requiredPermission = context.Selected.State == ContentState.Published ? Permission.Publish : Permission.Write; if (!context.Engine.SecurityManager.IsAuthorized(context.HttpContext.User, context.Selected, requiredPermission)) return null; if(!ActiveFor(container, context.State)) return null; if (!context.Selected.VersionOf.HasValue) return base.AddTo(container, context); HyperLink hl = new HyperLink(); hl.Text = GetInnerHtml(context, "{IconsUrl}/cross_orange.png", ToolTip, Title); hl.NavigateUrl = Url.Parse("{ManagementUrl}/Content/DiscardPreview.aspx").ResolveTokens() .AppendQuery("selectedUrl", context.Selected.Url) .AppendQuery(PathData.ItemQueryKey, context.Selected.VersionOf.ID) .AppendQuery(PathData.VersionIndexQueryKey, context.Selected.VersionIndex); hl.CssClass = "cancel"; hl.Attributes["onclick"] = "return confirm('Are you certain?');"; hl.ToolTip = Utility.GetResourceString(GlobalResourceClassName, Name + ".ToolTip") ?? context.Format("Delete this version", false); container.Controls.Add(hl); return hl; }
protected void AddLink(Control cssRoot, int InsertAt, HtmlLink link) { if (string.IsNullOrEmpty(Condition)) { if (InsertAt == -1) { cssRoot.Controls.Add(link); } else { cssRoot.Controls.AddAt(InsertAt, link); } } else { var openif = new Literal(); openif.Text = string.Format("<!--[if {0}]>", Condition); var closeif = new Literal(); closeif.Text = "<![endif]-->"; if (InsertAt == -1) { cssRoot.Controls.Add(openif); cssRoot.Controls.Add(link); cssRoot.Controls.Add(closeif); } else { //Since we want to add at a specific location, we do this in reverse order //this allows us to use the same insertion point cssRoot.Controls.AddAt(InsertAt, closeif); cssRoot.Controls.AddAt(InsertAt, link); cssRoot.Controls.AddAt(InsertAt, openif); } } }
public ICollection GenerateFields(Control control) { var itemControl = control as IDataBoundItemControl; var containerType = ((!(control is IDataBoundListControl) && !(control is Repeater)) && (control is IDataBoundItemControl)) ? ContainerType.Item : ContainerType.List; var mode = itemControl?.Mode ?? DataBoundControlMode.ReadOnly; var columns = _table.GetScaffoldColumns(mode, containerType); return SortColumns(_table, columns) .Select(col => { var field = new DynamicField() { DataField = col.Name, HeaderText = (containerType == ContainerType.List) ? col.ShortDisplayName : col.Name }; if (containerType != ContainerType.List) { field.ItemStyle.BorderWidth = 0; } field.ItemStyle.Wrap = false; return field; }) .ToList(); }
/// <summary> /// Adds Javascript code to safely set focus on the specified control. /// </summary> public static void Focus(this Web.UI.Control control, bool safe) { if (!safe) { control.Focus(); } var script = @"setTimeout(function() { var fn = function() { var control = $get('#CLIENT_ID#'); if (control && control.focus) { try { control.focus(); } catch (err) { } } try{ Sys.Application.remove_load(fn); } catch (err) { } }; Sys.Application.add_load(fn); fn(); }, 10);".Replace("#CLIENT_ID#", control.ClientID); ScriptManager.RegisterStartupScript(control.Page, control.GetType(), control.ClientID + "_SetFocusOnLoad", script, addScriptTags: true); }
private static void execute(IEntityPersistence entity, System.Web.UI.Control parent, bool enabled) { IViewControlEntity entityControl; foreach (System.Web.UI.Control control in parent.Controls) { if (control.Controls.Count > 0) { execute(entity, control, enabled); } else if (control is IViewControlEntity) { entityControl = control as IViewControlEntity; if (entityControl.EntitySource == entity.GetType().Name) { entityControl.SetValueToControl(entity); entityControl.Enabled = enabled; } } } }
public void InstantiateIn(System.Web.UI.Control container) { Literal lc = new Literal(); Image img = new Image(); switch (templateType) { case ListItemType.Header: lc.Text = "<B>" + columnName + "</B>"; container.Controls.Add(lc); break; case ListItemType.Item: img.ID = columnName + "_img"; img.Height = 12; img.Width = 12; img.ImageUrl = "~/PURCHASE/Image/view1.gif"; container.Controls.Add(img); container.Controls.Add(lc); break; } }
protected void clearallcontrols(System.Web.UI.Control parent) { foreach (System.Web.UI.Control c in parent.Controls) { if (c is TextBox) { ((TextBox)(c)).Text = ""; } if (c is RadioButton) { ((RadioButton)(c)).Checked = false; } clearallcontrols(c); } DropDownList1.SelectedIndex = 0; //DropDownList2.SelectedIndex = 0; //DropDownList3.SelectedIndex = 0; MultiView1.ActiveViewIndex = -1; GridView1.Visible = false; Button2.Visible = false; }
private void SetReadOnly(System.Web.UI.Control control) { foreach (System.Web.UI.Control child in control.Controls) { if (child is TextBox) { ((TextBox)child).ReadOnly = true; } if (child is DropDownList) { ((DropDownList)child).Enabled = false; } if (child is ICanReadOnly) { ((ICanReadOnly)child).ReadOnly = true; } if (child is Button) { ((Button)child).Enabled = false; } this.SetReadOnly(child); } }
/// <summary> /// Reads new values entered by the user for the field (as id) /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues) { ConnectionRequestPicker picker = control as ConnectionRequestPicker; if (picker != null) { int?id = picker.ItemId.AsIntegerOrNull(); if (id.HasValue) { using (var rockContext = new RockContext()) { var connectionRequest = new ConnectionRequestService(rockContext).GetNoTracking(id.Value); if (connectionRequest != null) { return(connectionRequest.Guid.ToString()); } } } } return(null); }
public void InstantiateIn(System.Web.UI.Control container) { switch (templateType) { case DataControlRowType.Header: Literal lc = new Literal(); lc.Text = headName; container.Controls.Add(lc); break; case DataControlRowType.DataRow: //TextBox tb = new TextBox(); //tb.ID = container.ClientID; LiteralControl lit = new LiteralControl(); lit.DataBinding += new EventHandler(DataBinding); container.Controls.Add(lit); break; default: break; } }
private void CreateSpacers() { // Finding out how many spacers we need... int numSpacers = 0; ASP.Control idxParent = this.Parent.Parent; while (idxParent is TreeNode) { numSpacers += 1; idxParent = idxParent.Parent.Parent; } // Creating our spacer elements... _spacers = new WEBCTRLS.Label[numSpacers]; // Looping through and instantiating our spacers... for (int idxNo = 0; idxNo < numSpacers; idxNo++) { _spacers[idxNo] = new WEBCTRLS.Label(); _spacers[idxNo].ID = "spacer" + idxNo; Controls.AddAt(0, _spacers[idxNo]); } }
protected override void OnInit(EventArgs e) { string path = Control; if (path.IndexOf("~") != 0) { if (!_relative) { path = string.Format("{0}/{1}", lw.CTE.Folders.UserControlsFolder, Control); } } if (!path.EndsWith(".ascx")) { path = path + ".ascx"; } System.Web.UI.Control ctrl = this.Page.LoadControl(path); this.Controls.Add(ctrl); base.OnInit(e); }
/// <summary> /// Creates the child controls. /// </summary> /// <param name="parentControl"></param> /// <returns></returns> public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl) { ddlCourses = new RockDropDownList { ID = parentControl.ID + "_ddlCourses", Label = "Course", DataTextField = "Name", DataValueField = "Id", Required = true }; parentControl.Controls.Add(ddlCourses); RockContext rockContext = new RockContext(); CourseService courseService = new CourseService(rockContext); var courses = courseService.Queryable().OrderBy(c => c.Name).ToList(); ddlCourses.DataSource = courses; ddlCourses.DataBind(); return(new Control[1] { ddlCourses }); }
protected void clearallcontrols(System.Web.UI.Control parent) { foreach (System.Web.UI.Control c in parent.Controls) { if (c is TextBox) { ((TextBox)(c)).Text = ""; } if (c is RadioButton) { ((RadioButton)(c)).Checked = false; } clearallcontrols(c); } TextArea1.InnerText = ""; TextArea2.InnerText = ""; lblMessage.Text = ""; DropDownList1.ClearSelection(); DropDownList2.ClearSelection(); DropDownList3.ClearSelection(); DropDownList3.Visible = false; btnUpload.Enabled = true; }
private void DisableControls(System.Web.UI.Control control) { foreach (System.Web.UI.Control c in control.Controls) { // Get the Enabled property by reflection. Type type = c.GetType(); System.Reflection.PropertyInfo prop = type.GetProperty("Enabled"); // Set it to False to disable the control. if (prop != null) { if (type != typeof(System.Web.UI.WebControls.Menu)) { prop.SetValue(c, false, null); } } // Recurse into child controls. if (c.Controls.Count > 0) { this.DisableControls(c); } } }
/// <summary> /// /// </summary> /// <typeparam name="Page"></typeparam> /// <param name="userControlPath"></param> /// <param name="id"></param> /// <returns></returns> public static UserControl LoadControl <Page>(string userControlPath, string id) where Page : System.Web.UI.Page, ISelfRenderingPage, new() { System.Web.UI.Page pageHolder = (System.Web.UI.Page) new Page(); ResourceManager rm = new ResourceManager(true); rm.RenderScripts = ResourceLocationType.None; rm.RenderStyles = ResourceLocationType.None; rm.IDMode = IDMode.Explicit; pageHolder.Controls.Add(rm); if (!userControlPath.StartsWith("~") && !userControlPath.StartsWith("/") && HttpContext.Current != null && HttpContext.Current.CurrentHandler is System.Web.UI.Page) { string dir = System.IO.Path.GetDirectoryName(HttpContext.Current.Request.CurrentExecutionFilePath).Replace("\\", "/"); userControlPath = dir + "/" + userControlPath; } id = id ?? BaseControl.GenerateID(); System.Web.UI.Control uc = pageHolder.LoadControl(userControlPath); uc.ID = id; return((UserControl)uc); }
/// <summary> /// Para cada WebControl da collection controls, será atribuído true ou false para a propriedade Enabled. /// </summary> /// <param name="controls">Lista de controles</param> /// <param name="enabled">True para habilitar todos os controles da lista controls; false caso contrário.</param> /// <param name="clear">True para limpar todos os controles da lista controls; false caso contrário.</param> private static void execute(System.Web.UI.Control parent, bool enabled, bool clear, string entitySource) { foreach (System.Web.UI.Control control in parent.Controls) { if (control.Controls.Count > 0) { execute(control, enabled, clear, entitySource); } else if (control is IViewControlEntity) { if (entitySource == string.Empty || entitySource == (control as IViewControlEntity).EntitySource) { (control as IViewControlEntity).Enabled = enabled; if (clear) { (control as IViewControlEntity).SetValueToControl(null); } } } } }
public void InstantiateIn(System.Web.UI.Control container) { switch (templateType) { case DataControlRowType.Header: Literal lc = new Literal(); lc.Text = columnName; container.Controls.Add(lc); break; case DataControlRowType.DataRow: HyperLink lbtn = new HyperLink(); lbtn.ID = this.controlID; lbtn.Text = columnName; if (eh != null) { //lbtn.Click += new System.EventHandler(eh); } //lbtn.DataBinding += new System.EventHandler(lbtn_DataBinding); container.Controls.Add(lbtn); break; default: break; } }
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) { string s = ItemTemplate.ToString(); switch (cellType) { case DataControlCellType.DataCell: System.Web.UI.Control c = new System.Web.UI.Control(); ItemTemplate.InstantiateIn(c); cell.Controls.Add(c); EditWindow = new RadWindow(); EditWindow.Modal = true; EditWindow.VisibleStatusbar = false; EditWindow.Height = 350; EditWindow.Width = 490; EditWindow.DestroyOnClose = false; EditWindow.Title = "Edit Performance Indicator Metrics"; cell.Controls.Add(EditWindow); Control.PreRender += new EventHandler(Control_PreRender); break; case DataControlCellType.Header: if (!string.IsNullOrEmpty(HeaderText)) { cell.Controls.Add(new LiteralControl(HeaderText + "<br>")); } EditLink = new HyperLink(); EditLink.Text = "Edit"; cell.Controls.Add(EditLink); break; } }
//- @InstantiateIn -// public void InstantiateIn(System.Web.UI.Control container) { System.Web.UI.WebControls.PlaceHolder pane = new System.Web.UI.WebControls.PlaceHolder(); switch (type) { case ListItemType.Header: pane.Controls.Add(new System.Web.UI.WebControls.Literal { Text = "<ul id=\"" + listCssClass + "\">" }); break; case ListItemType.Item: System.Web.UI.WebControls.Literal literal = new System.Web.UI.WebControls.Literal(); literal.DataBinding += new EventHandler(delegate(Object sender, EventArgs ea) { IDataItemContainer item = (IDataItemContainer)container; String url = DataBinder.Eval(item.DataItem, "Url").ToString(); String title = DataBinder.Eval(item.DataItem, "Title").ToString(); String entryCount = DataBinder.Eval(item.DataItem, "EntryCount").ToString(); //+ literal.Text = @"<li><a href=""{Url}"">{Title} ({EntryCount})</a></li>" .Replace("{Url}", url) .Replace("{Title}", title) .Replace("{EntryCount}", entryCount); }); pane.Controls.Add(literal); break; case ListItemType.Footer: pane.Controls.Add(new System.Web.UI.WebControls.Literal { Text = "</ul>" }); break; } //+ container.Controls.Add(pane); }
public void InstantiateIn(System.Web.UI.Control container) { PlaceHolder ph = new PlaceHolder(); TextBox oCrit1 = new TextBox(); oCrit1.ID = "item"; oCrit1.Width = 420; oCrit1.ReadOnly = true; switch (templateType) { case ListItemType.Header: //ph.Controls.Add(new LiteralControl("<td runat='server'><span style='width: 150px;'>")); //ph.Controls.Add(new LiteralControl("<td><table border=\"0\"><tbody><tr>")); break; case ListItemType.Item: ph.Controls.Add(new LiteralControl("<td runat='server'>")); ph.Controls.Add(oCrit1); ph.Controls.Add(new LiteralControl("</td>")); ph.DataBinding += new EventHandler(Item_DataBinding); break; case ListItemType.AlternatingItem: ph.Controls.Add(new LiteralControl("<td runat='server'>")); ph.Controls.Add(oCrit1); ph.Controls.Add(new LiteralControl("</td>")); ph.DataBinding += new EventHandler(Item_DataBinding); break; case ListItemType.Footer: //ph.Controls.Add(new LiteralControl("</span></td>")); //ph.Controls.Add(new LiteralControl("</tr></tbody></table></td>")); break; } container.Controls.Add(ph); }
public void InstantiateIn(System.Web.UI.Control container) { PlaceHolder placeHolder = new PlaceHolder(); if (_templateType == ListItemType.Item) { HtmlTableRow row = new HtmlTableRow(); HtmlTableCell cell = new HtmlTableCell("td"); cell.Width = "100%"; ImageButton childImage = new ImageButton(); childImage.ID = "img"; Unit imageWidth = new Unit("60px"); childImage.Width = imageWidth; Unit imageHieght = new Unit("75px"); childImage.Height = imageHieght; childImage.BorderStyle = BorderStyle.Double; childImage.CssClass = "ms-quickLaunch"; childImage.Click += new ImageClickEventHandler(ChildImage_Clicked); Label childLabel = new Label(); childLabel.ID = "lbl"; cell.Controls.Add(childImage); cell.Controls.Add(new LiteralControl("<br>")); cell.Controls.Add(childLabel); cell.Controls.Add(new LiteralControl("<br>")); cell.Controls.Add(new LiteralControl("<br>")); row.Cells.Add(cell); placeHolder.Controls.Add(row); placeHolder.DataBinding += new EventHandler(PlaceHolder_DataBinding); } container.Controls.Add(placeHolder); }
internal void RollUpAllExceptThis(MenuItems menuItems, ASP.ControlCollection cols) { foreach (ASP.Control idx in cols) { if (idx is MenuItems) { MenuItems items = idx as MenuItems; if (!items.Expanded) { continue; } bool isParent = false; ASP.Control idxCtrl = menuItems; while (idxCtrl != null && !(idxCtrl is Menu)) { if (idxCtrl == items) { isParent = true; break; } idxCtrl = idxCtrl.Parent; } if (!isParent) { items.Expanded = false; items.RollUp(); } else { foreach (ASP.Control idxInner in idx.Controls) { RollUpAllExceptThis(menuItems, idxInner.Controls); } } } } }
/// <summary> /// Creates the child controls. /// </summary> /// <param name="parentControl"></param> /// <returns></returns> public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl) { var groupTypePicker = new GroupTypePicker(); groupTypePicker.ID = parentControl.ID + "_groupTypePicker"; groupTypePicker.Label = "Group Type"; groupTypePicker.GroupTypes = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList(); groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged; groupTypePicker.AutoPostBack = true; parentControl.Controls.Add(groupTypePicker); int?selectedGroupTypeId = parentControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull(); groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId; var cblRole = new RockCheckBoxList(); cblRole.Label = "with Group Role(s)"; cblRole.ID = parentControl.ID + "_cblRole"; parentControl.Controls.Add(cblRole); PopulateGroupRolesCheckList(groupTypePicker.SelectedGroupTypeId ?? 0, cblRole); RockDropDownList ddlGroupMemberStatus = new RockDropDownList(); ddlGroupMemberStatus.CssClass = "js-group-member-status"; ddlGroupMemberStatus.ID = parentControl.ID + "_ddlGroupMemberStatus"; ddlGroupMemberStatus.Label = "with Group Member Status"; ddlGroupMemberStatus.Help = "Select a specific group member status only include to only show true for group members with that status. Leaving this blank will return true for all members."; ddlGroupMemberStatus.BindToEnum <GroupMemberStatus>(true); ddlGroupMemberStatus.SetValue(GroupMemberStatus.Active.ConvertToInt()); parentControl.Controls.Add(ddlGroupMemberStatus); return(new Control[3] { groupTypePicker, cblRole, ddlGroupMemberStatus }); }
public void InstantiateIn(System.Web.UI.Control container) { if (index == tabCount - 1) { ASPxButton new_btn = new ASPxButton(); new_btn.ID = "newBtn" + container.ID; container.Controls.Add(new_btn); new_btn.Width = 100; new_btn.Height = 25; new_btn.Text = "Open New Tab"; new_btn.AutoPostBack = false; new_btn.ClientSideEvents.Click = "function(s, e) { createNewTab(); }"; } else { ASPxButton close_btn = new ASPxButton(); close_btn.ID = "closeBtn" + container.ID; container.Controls.Add(close_btn); close_btn.ImageUrl = "~/Images/Close.png"; close_btn.ImagePosition = DevExpress.Web.ASPxClasses.ImagePosition.Right; close_btn.AutoPostBack = false; close_btn.ClientSideEvents.Click = "function(s, e) { closeActiveTab(); }"; } }
protected void shoppingCartProductList_ItemCommand(object sender, System.Web.UI.WebControls.DataListCommandEventArgs e) { System.Web.UI.Control control = e.Item.Controls[0]; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)control.FindControl("txtBuyNum"); System.Web.UI.WebControls.Literal literal = (System.Web.UI.WebControls.Literal)control.FindControl("litSkuId"); int num; if (!int.TryParse(textBox.Text, out num) || textBox.Text.IndexOf(".") != -1) { this.ShowMessage("购买数量必须为整数", false); } else { if (num <= 0) { this.ShowMessage("购买数量必须为大于0的整数", false); } else { if (e.CommandName == "updateBuyNum") { if (ShoppingCartProcessor.GetSkuStock(literal.Text.Trim()) < num) { this.ShowMessage("该商品库存不够", false); return; } ShoppingCartProcessor.UpdateLineItemQuantity(literal.Text, num); } if (e.CommandName == "delete") { ShoppingCartProcessor.RemoveLineItem(literal.Text); } this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); } } }
/// <summary> /// Reads new values entered by the user for the field ( as Guid ) /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues) { GroupTypeGroupPicker groupTypeGroupPicker = control as GroupTypeGroupPicker; if (groupTypeGroupPicker != null) { var rockContext = new RockContext(); Guid?groupTypeGuid = null; Guid?groupGuid = null; if (groupTypeGroupPicker.GroupTypeId.HasValue) { var groupType = new GroupTypeService(rockContext).Get(groupTypeGroupPicker.GroupTypeId.Value); if (groupType != null) { groupTypeGuid = groupType.Guid; } } if (groupTypeGroupPicker.GroupId.HasValue) { var group = new GroupService(rockContext).Get(groupTypeGroupPicker.GroupId.Value); if (group != null) { groupGuid = group.Guid; } } if (groupTypeGuid.HasValue || groupGuid.HasValue) { return(string.Format("{0}|{1}", groupTypeGuid, groupGuid)); } } return(null); }
/// <summary> /// Creates elements based on the fields in a database. /// Optionally, the elements are enclosed in a from with ID 'form_[formID]'. /// </summary> /// <param name="appID">The appID on which these controls are based.</param> /// <param name="cntlContainer">The container that contains these controls</param> /// <param name="dctDefaultOverride">A dictionary that maps the default value given in the database /// with the value to use as an override</param> /// <param name="uid">A unique identified to append to the control IDs of the generated controls. /// You will need this if you are calling this method several times to generate similar output one page. /// (One recommended value for thie Unique ID is the Database ID).</param> /// <param name="cntlDisplayStyle"></param> /// <param name="blElementsInLine">Set false to allow displaying all elements in line (no line breaks)</param> /// <param name="blRunAtServer">When TRUE, includes runat=server as a property of all controls</param> public static void GenerateControlsFromDatabase(int appID, System.Web.UI.Control cntlContainer, Dictionary <string, string> dctDefaultOverride = null, string uid = "", int cntlDisplayStyle = -1, Boolean blElementsInLine = false, Boolean blRunAtServer = false) { try { if (dctDefaultOverride == null) { dctDefaultOverride = new Dictionary <string, string>(); } SqlCommand cmd = new SqlCommand(); clsDB myDB = new clsDB(); ControlCollection cntls = new ControlCollection(cntlContainer); List <SqlParameter> ps = new List <SqlParameter>(); ps.Add(new SqlParameter("@" + DBK.fkAPPID, appID)); using (myDB.OpenConnection()) { using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(DBK.SP.spGETWEBDISPLAYFIELDINFO, ps, clsDB.SPExMode.READER, ref cmd) ) { if ((dR != null) && (dR.HasRows)) { CustomCode x = new CustomCode(); x.ConstructInputControls(dR, cntlContainer, dctDefaultOverride, uid, cntlDisplayStyle, blElementsInLine, blRunAtServer); } } } } catch (Exception ex) { cntlContainer.Controls.Add(renderLiteralControlError(ex, "")); } }
/// <summary> /// Find control by control id from a control container. /// <code> /// TextBox txt_name = (TextBox)State.FindControl("txt_name",this); /// </code> /// </summary> /// <param name="controlId">control id to find.</param> /// <param name="control">control container.</param> /// <returns>The result control.</returns> public System.Web.UI.Control FindControl(string controlId, System.Web.UI.Control control) { System.Web.UI.Control _result = null; foreach (System.Web.UI.Control _control in control.Controls) { if (_control.ID == controlId) { _result = _control; break; } else { if (_control.HasControls()) { _result = FindControl(controlId, _control); if (_result != null) { break; } } } } return(_result); }
//这种方式导出的不是标准的Excel格式,不能再次导入,要修改,暂时不做修改 public void ExportByApplication(System.Web.UI.Control ctl, string fileName) { string style = @"<style type='text/css'> .text { mso-number-format:\@; } </style> "; Response.ClearContent(); Response.Charset = "GB2312"; // Response.ContentEncoding = System.Text.Encoding.UTF8; //Response.ContentType = "application/ms-excel"; Response.ContentType = "application/vnd.ms-excel "; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">"); if (Request.Browser.Browser.ToLower() == "ie") { Response.AppendHeader("Content-Disposition", "attachment;filename=" + "" + HttpUtility.UrlEncode(fileName + ".xls", Encoding.UTF8)); } else { Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls"); } ctl.Page.EnableViewState = false; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); ctl.RenderControl(hw); Response.Write(style); Response.Write(tw.ToString()); Response.End(); }
/////////////////////////////////////////////////////////////////////// // Returns an HTMLControl or WebControl by its id. public static Control find_control(ControlCollection controls, string id) { foreach (System.Web.UI.Control c in controls) { if (c.ID == id) { return(c); } else { if (c.Controls.Count > 0) { System.Web.UI.Control c2 = null; c2 = find_control(c.Controls, id); if (c2 != null) { return(c2); } } } } return(null); }
public static void DisableAll(System.Web.UI.Control oMe, string strRole_id) { int cnt = oMe.Controls.Count; for (int i = 0; i < cnt; i++) { if ((oMe.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.TextBox")) { ((System.Web.UI.WebControls.TextBox)oMe.Controls[i]).Enabled = false; } else if ((oMe.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.LinkButton")) { ((System.Web.UI.WebControls.LinkButton)oMe.Controls[i]).Enabled = false; } else if ((oMe.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.DropDownList")) { ((System.Web.UI.WebControls.DropDownList)oMe.Controls[i]).Enabled = false; } else if ((oMe.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.Button")) { ((System.Web.UI.WebControls.Button)oMe.Controls[i]).Enabled = false; } else if ((oMe.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.CheckBoxList")) { ((System.Web.UI.WebControls.CheckBoxList)oMe.Controls[i]).Enabled = false; } else if ((oMe.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.RadioButtonList")) { ((System.Web.UI.WebControls.RadioButtonList)oMe.Controls[i]).Enabled = false; } if (oMe.Controls[i].HasControls()) { DisableAll(oMe.Controls[i], strRole_id); } } }
public static System.Web.UI.Control GetPostBackControl(Page page) { System.Web.UI.Control control = null; string ctrlname = page.Request.Params.Get("__EVENTTARGET"); if (ctrlname != null && ctrlname != string.Empty) { control = page.FindControl(ctrlname); } else { foreach (string ctl in page.Request.Form) { System.Web.UI.Control c = page.FindControl(ctl); if (c is System.Web.UI.WebControls.Button) { control = c; break; } } } return(control); }