FindControl() private method

private FindControl ( string id ) : Control
id string
return Control
Example #1
2
        public override Control AddTo(Control container)
        {
            // If the current container doesn't already contain a TabControl, create one now.
            CustomTabPanel tabControl = container.FindControl("TabControl") as CustomTabPanel;
            if (tabControl == null)
            {
                tabControl = new CustomTabPanel { ID = "TabControl" };
                if (container is ContentPanel)
                    ((ContentPanel) container).ContentControls.Add(tabControl);
                else
                    container.Controls.Add(tabControl);
            }

            Panel tabItem = new Panel
            {
                AutoScroll = true,
                AutoHeight = true,
                AutoWidth = true,
                ID = "tabItem" + Name,
                Title = Title,
                BodyStyle = "padding:5px"
            };
            tabControl.Items.Add(tabItem);
            return tabItem;
        }
        public void ControlParameter(Control _control, string title, string icon, string value, int record)
        {
            //Control _controlsTitle = _control.FindControl("lblTitle");
            //if (_controlsTitle != null)
            //{
            //    Type objTypeTitle = _controlsTitle.GetType();
            //    if (objTypeTitle.Name == "Label")
            //    {
            //        Label objlbl = (Label)_controlsTitle;
            //        objlbl.Text = title;
            //    }
            //}

            Control _controlsTitle = _control.FindControl("hddTitle");
            if (_controlsTitle != null)
            {
                Type objTypeTitle = _controlsTitle.GetType();
                if (objTypeTitle.Name == "HiddenField")
                {
                    HiddenField objlbl = (HiddenField)_controlsTitle;
                    objlbl.Value = title;
                }
            }

            Control _controlsIcon = _control.FindControl("imgIcon");
            if (_controlsIcon != null)
            {
                Type objTypeIcon = _controlsIcon.GetType();
                if (objTypeIcon.Name == "Image")
                {
                    Image objimg = (Image)_controlsIcon;
                    objimg.ImageUrl = "~/Upload/Admin_Theme/Icons/" + icon;
                }
            }


            Control _controlsValue = _control.FindControl("hddValue");
            if (_controlsValue != null)
            {
                Type objTypeValue = _controlsValue.GetType();
                if (objTypeValue.Name == "HiddenField")
                {
                    HiddenField objvalue = (HiddenField)_controlsValue;
                    objvalue.Value = value;
                }
            }

            Control _controlsRecord = _control.FindControl("hddRecord");
            if (_controlsRecord != null)
            {
                Type objTypeRecord = _controlsRecord.GetType();
                if (objTypeRecord.Name == "HiddenField")
                {
                    HiddenField objRecord = (HiddenField)_controlsRecord;
                    objRecord.Value = record.ToString();
                }
            }
        }
        public void ControlParameter(Control control, string title, string icon, string value, int record, string content)
        {
            var controlsTitle = control.FindControl("Literal1");
            if (controlsTitle != null)
            {
                var objTypeTitle = controlsTitle.GetType();
                if (objTypeTitle.Name == "Literal")
                {
                    var objlbl = (Literal)controlsTitle;
                    objlbl.Text = title;
                }
            }

            var controlsIcon = control.FindControl("imgIcon");
            if (controlsIcon != null)
            {
                var objTypeIcon = controlsIcon.GetType();
                if (objTypeIcon.Name == "Image")
                {
                    var objimg = (Image)controlsIcon;
                    objimg.ImageUrl = "~/Upload/Admin_Theme/Icons/" + icon;
                }
            }

            var controlsValue = control.FindControl("hddValue");
            if (controlsValue != null)
            {
                var objTypeValue = controlsValue.GetType();
                if (objTypeValue.Name == "HiddenField")
                {
                    var objvalue = (HiddenField)controlsValue;
                    objvalue.Value = value;
                }
            }

            var controlsRecord = control.FindControl("hddRecord");
            if (controlsRecord != null)
            {
                var objTypeRecord = controlsRecord.GetType();
                if (objTypeRecord.Name == "HiddenField")
                {
                    var objRecord = (HiddenField)controlsRecord;
                    objRecord.Value = record.ToString();
                }
            }

            var controlsContent = control.FindControl("hddContent");
            if (controlsContent != null)
            {
                var objTypeContent = controlsContent.GetType();
                if (objTypeContent.Name == "HiddenField")
                {
                    var objContent = (HiddenField)controlsContent;
                    objContent.Value = content.ToString();
                }
            }
        }
        public void ControlParameter(Control control, string title, string icon, string value, int record, string panelId)
        {
            var controlsTitle = control.FindControl("hddTitle");
            if (controlsTitle != null)
            {
                var objTypeTitle = controlsTitle.GetType();
                if (objTypeTitle.Name == "HiddenField")
                {
                    var objlbl = (HiddenField)controlsTitle;
                    objlbl.Value = title;
                }
            }

            var controlsIcon = control.FindControl("imgIcon");
            if (controlsIcon != null)
            {
                var objTypeIcon = controlsIcon.GetType();
                if (objTypeIcon.Name == "Image")
                {
                    var objimg = (Image)controlsIcon;
                    objimg.ImageUrl = "~/Upload/Admin_Theme/Icons/" + icon;
                }
            }

            var controlsValue = control.FindControl("hddValue");
            if (controlsValue != null)
            {
                var objTypeValue = controlsValue.GetType();
                if (objTypeValue.Name == "HiddenField")
                {
                    var objvalue = (HiddenField)controlsValue;
                    objvalue.Value = value;
                }
            }

            var controlsRecord = control.FindControl("hddRecord");
            if (controlsRecord != null)
            {
                var objTypeRecord = controlsRecord.GetType();
                if (objTypeRecord.Name == "HiddenField")
                {
                    var objRecord = (HiddenField)controlsRecord;
                    objRecord.Value = record.ToString();
                }
            }

            var controlsId = control.FindControl("hdfPanelId");
            if (controlsId != null)
            {
                var objTypePnId = controlsId.GetType();
                if (objTypePnId.Name == "HiddenField")
                {
                    var objPnId = (HiddenField)controlsId;
                    objPnId.Value = panelId;
                }
            }
        }
Example #5
0
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        // ***********************************************************************/
        protected override void InitializeSkin(Control skin)
        {
            IDataProviderBase dp = DataProvider.Instance();
            int LC;
            LC = dp.GetLastCount((UlterSystems.PortalLib.BusinessObjects.Person.RequestUser().ID).ToString());

            // Find the thread tracking thread list control
            threadTracking = (ThreadList)skin.FindControl("ThreadTracking");
            if (null != threadTracking)
            {
                ThreadCollection trackedThreads = Threads.GetThreadsUserIsTracking(ForumUser.Username);

                if (trackedThreads.Count > 0)
                {
                    threadTracking.DataSource = trackedThreads;
                    threadTracking.DataBind();
                }
                else
                {
                    threadTracking.Visible = false;
                    Label label = (Label)skin.FindControl("NoTrackedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }

                }
            }

            // Find the participated threads control
            participatedThreads = (ThreadList)skin.FindControl("ParticipatedThreads");
            LastCount = (DropDownList)skin.FindControl("LastCount");
            LastCount.SelectedIndex = (LC - 5) / 5;
            LastCount.SelectedIndexChanged += new System.EventHandler(LastCount_SelectedIndexChanged);
            LastCount_SelectedIndexChanged(null, null);

            if (null != participatedThreads)
            {
                ThreadCollection participatedInThreads = Threads.GetThreadsUserMostRecentlyParticipatedIn(ForumUser.Username, LC);

                if (participatedInThreads.Count > 0)
                {
                    participatedThreads.DataSource = participatedInThreads;
                    participatedThreads.DataBind();
                }
                else
                {
                    participatedThreads.Visible = false;
                    Label label = (Label)skin.FindControl("NoParticipatedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }
                }
            }
        }
        public void FindControl()
        {
            // Type
            var @this = new Control();
            @this.Controls.Add(new Literal {ID = "Fizz"});

            // Examples
            var value1 = @this.FindControl<Literal>("Fizz"); // return control as Literal.
            var value2 = @this.FindControl<Literal>("Buzz"); // return null;
        }
Example #7
0
 /// <summary>
 /// mtodo para obter o control que existe na skin que estamos
 /// a carregar
 /// </summary>
 /// <param name="skin">a skin corrente</param>
 /// <param name="controlName">nome do control a procurar</param>
 /// <returns>o control que est associado ao nome</returns>
 public Control getControl(Control skin, string controlName)
 {
     Control ctrl = skin.FindControl(controlName);
     if (ctrl == null)
         throw new AlnitakException( "Nao foi possivel encontrar o controlo "+ controlName +" na skin "+ skin.ToString() );
     return ctrl;
 }
        internal static Control FindTargetControl(string controlID, Control control, bool searchNamingContainers) {
            Control foundControl;
            if (searchNamingContainers) {
                Control currentContainer;
                foundControl = null;

                // DevDiv 73305: Do not assume starting control is not a naming container.
                if (control is INamingContainer) {
                    currentContainer = control;
                }
                else {
                    currentContainer = control.NamingContainer;
                }

                do {
                    foundControl = currentContainer.FindControl(controlID);
                    currentContainer = currentContainer.NamingContainer;
                }
                while (foundControl == null && currentContainer != null);
            }
            else {
                foundControl = control.FindControl(controlID);
            }

            return foundControl;
        }
        /// <summary>
        /// ��ʵ�嵽�ؼ�
        /// </summary>
        /// <param name="entity">ʵ��</param>
        /// <param name="container">�ؼ�</param>
        public static void BindObjectToControls(object entity, Control container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (entity == null) return;

            Type type = entity.GetType();
            PropertyInfo[] propertiesArray = type.GetProperties();

            foreach (PropertyInfo property in propertiesArray)
            {
                Control control = container.FindControl(property.Name);
                if (control == null) continue;

                if (control is ListControl)
                {
                    SetListControl(entity, property, control);
                }
                else
                {
                    SetGeneralControl(entity, property, control);
                }
            }
        }
Example #10
0
        /// <summary>
        /// �󶨿ؼ���ʵ��
        /// </summary>
        /// <param name="entity">ʵ��</param>
        /// <param name="container">�ؼ�</param>
        public static void BindControlsToObject(object entity, Control container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (entity == null) return;

            Type objType = entity.GetType();
            PropertyInfo[] objPropertiesArray = objType.GetProperties();

            foreach (PropertyInfo objProperty in objPropertiesArray)
            {
                Control control = container.FindControl(objProperty.Name.ToLower(CultureInfo.InvariantCulture));
                if (control == null) continue;
                if (control is ListControl)
                {
                    SetListObject(entity, objProperty, control);
                }
                else
                {
                    SetGeneralObject(entity, objProperty, control);
                }
            }
        }
Example #11
0
 protected void AddTitleAttribute(Control container, string checkBoxName)
 {
     CheckBox cb = (CheckBox)container.FindControl(checkBoxName);
     if (cb != null) {
         cb.InputAttributes.Add("title", (string)GetGlobalResourceObject("GlobalResources", "AutoPostBackCheckBoxWarning"));
     }
 }
        public override bool UpdateItem(ContentItem item, Control editor)
        {
            var textBox = (TextBox)editor.FindControl(Name);
            item[Name] = textBox.Text;

            return true;
        }
Example #13
0
 public static Control FindControlRecursive( Control objParent, string strControlName, string strClientID )
 {
     Control control = objParent.FindControl( strControlName );
     if( control != null )
     {
         return control;
     }
     foreach( Control parent in objParent.Controls )
     {
         if( parent.HasControls() )
         {
             control = FindControlRecursive( parent, strControlName, strClientID );
         }
         // HACK : Modified to not error if object is null.
         //if( ( ( control != null ) && ( strClientID.Length > 0 ) ) && ( String.Compare( control.ClientID, strClientID, false ) != 0 ) )
         if (((control != null) && (!String.IsNullOrEmpty(strClientID))) && (String.Compare(control.ClientID, strClientID, false) != 0))
         {
             control = null;
         }
         if( control != null )
         {
             return control;
         }
     }
     return control;
 }
 private void ExtractTemplateValuesRecursive(ArrayList subBuilders, OrderedDictionary table, Control container)
 {
     foreach (object obj2 in subBuilders)
     {
         ControlBuilder builder = obj2 as ControlBuilder;
         if (builder != null)
         {
             ICollection boundPropertyEntries;
             if (!builder.HasFilteredBoundEntries)
             {
                 boundPropertyEntries = builder.BoundPropertyEntries;
             }
             else
             {
                 ServiceContainer serviceProvider = new ServiceContainer();
                 serviceProvider.AddService(typeof(IFilterResolutionService), builder.TemplateControl);
                 try
                 {
                     builder.SetServiceProvider(serviceProvider);
                     boundPropertyEntries = builder.GetFilteredPropertyEntrySet(builder.BoundPropertyEntries);
                 }
                 finally
                 {
                     builder.SetServiceProvider(null);
                 }
             }
             string strA = null;
             bool flag = true;
             Control o = null;
             foreach (BoundPropertyEntry entry in boundPropertyEntries)
             {
                 if (entry.TwoWayBound)
                 {
                     string str2;
                     if (string.Compare(strA, entry.ControlID, StringComparison.Ordinal) != 0)
                     {
                         flag = true;
                     }
                     else
                     {
                         flag = false;
                     }
                     strA = entry.ControlID;
                     if (flag)
                     {
                         o = container.FindControl(entry.ControlID);
                         if ((o == null) || !entry.ControlType.IsInstanceOfType(o))
                         {
                             continue;
                         }
                     }
                     object target = PropertyMapper.LocatePropertyObject(o, entry.Name, out str2, base.InDesigner);
                     table[entry.FieldName] = FastPropertyAccessor.GetProperty(target, str2, base.InDesigner);
                 }
             }
             this.ExtractTemplateValuesRecursive(builder.SubBuilders, table, container);
         }
     }
 }
Example #15
0
        public override bool UpdateItem(ContentItem item, Control editor)
        {
            ContentItem questionItem = Utility.GetProperty(item, Name) as ContentItem;

            CheckBox cb = editor.FindControl(GetCheckBoxName()) as CheckBox;
            if (cb.Checked || questionItem == null)
            {
                questionItem = new SingleSelect();
                questionItem.AddTo(item);
                Utility.UpdateSortOrder(item.Children);
            }

            TextBox tb = editor.FindControl(GetTextBoxName()) as TextBox;
            questionItem.Title = tb.Text;

            return base.UpdateItem(questionItem, editor);
        }
Example #16
0
        /// <summary>Preenche os controlos relativos a um recurso</summary>
        private void fillResourceType( string resource, Control control, Chronos.Core.Planet planet)
        {
            QueueItem item = planet.current(resource);

            Label type = (Label) control.FindControl("resource" + resource);
            if( type != null ) {
                if( item != null ) {
                    type.EnableViewState = false;
                    if( item == null ) {
                        type.Text = "-";
                    } else {
                        string resType = info.getContent(item.FactoryName);
                        type.Text = resType;
                    }
                } else {
                    type.Text = "-";
                }
            }

            Label queueCount = (Label) control.FindControl("queueCount" + resource);
            if( queueCount != null ) {
                queueCount.EnableViewState = false;
                queueCount.Text = planet.queueCount(resource).ToString();
            }

            Label quantity = (Label) control.FindControl("quantity" + resource);
            if( quantity != null ) {
                if( item != null ) {
                    quantity.EnableViewState = false;
                    quantity.Text = item.Quantity.ToString();
                } else {
                    quantity.Text = "-";
                }
            }

            Label toGo = (Label) control.FindControl("toGo" + resource);
            if( toGo != null ) {
                if( item != null ) {
                    toGo.EnableViewState = false;
                    toGo.Text = "+ " + item.RemainingTurns;
                } else {
                    toGo.Text = "-";
                }
            }
        }
Example #17
0
        /// <summary>Inicializa uma Label</summary>
        private void fillLabel( Control container, string label, string text )
        {
            Label control = (Label) container.FindControl(label);

            if( control != null ) {
                control.EnableViewState = false;
                control.Text = text;
            }
        }
Example #18
0
 /// <summary>Preenche um Panel</summary>
 private void fillPanel( Control container, string label, int val )
 {
     Panel panel = (Panel) container.FindControl(label);
     if( panel != null ) {
         panel.EnableViewState = false;
         panel.Width = new Unit(val, UnitType.Percentage);
         panel.Controls.Add( new LiteralControl(val.ToString() + "%") );
     }
 }
Example #19
0
        public override void UpdateEditor(ContentItem item, Control editor)
        {
            ContentItem questionItem = Utility.GetProperty(item, Name) as ContentItem
                                       ?? new SingleSelect();

            TextBox tb = editor.FindControl(GetTextBoxName()) as TextBox;
            tb.Text = questionItem.Title;

            base.UpdateEditor(questionItem, editor);
        }
    public override void SaveValidatorSettings(Control parentCtrl)
    {
      this.Data.Properties.Clear();

      TextBox expressionBox = (TextBox)parentCtrl.FindControl("_expression");
      if (expressionBox != null)
      {
        this.Data.Properties["Regex"] = HttpContext.Current.Server.HtmlEncode(expressionBox.Text);
      }
    }
        private string GetTextFromInnerControl(Control control, string innerControlID)
        {
            TextBox field = control.FindControl(innerControlID) as TextBox;
            if (field == null)
            {
                return null;
            }

            return field.Text.Trim();
        }
Example #22
0
 public static void SetControlValue(Control container, string ctrlId, object val)
 {
     var ctrl = container.FindControl(ctrlId);
     if (ctrl==null) return;
     if (ctrl is ITextControl)
         ((ITextControl)ctrl).Text = Convert.ToString(val);
     if (ctrl is ICheckBoxControl)
         ((ICheckBoxControl)ctrl).Checked = ConvertManager.ChangeType<bool>(val);
     if (ctrl is IDateBoxControl)
         ((IDateBoxControl)ctrl).Date = AssertHelper.IsFuzzyEmpty(val) ? null : (DateTime?)ConvertManager.ChangeType<DateTime>(val);
 }
Example #23
0
        public static Control FindChildControl(Control ctl, string id)
        {
            Control target = ctl.FindControl(id);

            if (target != null) return target;
            foreach (Control c in ctl.Controls)
            {
                target = FindChildControl(c, id);
                if (target != null) return target;
            }
            return target;
        }
        private static int? GetJobGroupId(Control row)
        {
            var jobGroupIdHiddenField = (HiddenField)row.FindControl("JobGroupIdHiddenField");

            int jobGroupId;
            if (jobGroupIdHiddenField != null && int.TryParse(jobGroupIdHiddenField.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out jobGroupId))
            {
                return jobGroupId;
            }

            return null;
        }
        /// <summary>Gets the ID of the status represented in the given row.</summary>
        /// <param name="row">The row representing a status.</param>
        /// <returns>The ID of the status represented in the given row</returns>
        private static int? GetStatusId(Control row)
        {
            var statusIdHiddenField = (HiddenField)row.FindControl("StatusIdHiddenField");

            int statusId;
            if (statusIdHiddenField != null && int.TryParse(statusIdHiddenField.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out statusId))
            {
                return statusId;
            }

            return null;
        }
Example #26
0
 public static Control FindControlReqursive(string controlId, Control parent)
 {
     foreach (Control control in parent.Controls)
     {
         Control result = FindControlReqursive(controlId, control);
         if (result != null)
         {
             return result;
         }
     }
     return parent.FindControl(controlId);
 }
Example #27
0
        /// <summary>Preenche os controlos relativos a um recurso</summary>
        private void fillResource( string resource, Control control, Chronos.Core.Planet planet)
        {
            Label quantity = (Label) control.FindControl(resource + "Quantity");
            if( quantity != null ) {
                quantity.EnableViewState = false;
                int val = planet.getResourceCount(resource);
                quantity.Text = val.ToString();
                if( val < 0 ) {
                    quantity.CssClass = "error";
                }
            }

            Label ratio = (Label) control.FindControl(resource + "Ratio");
            if( ratio != null ) {
                ratio.EnableViewState = false;
                int val = planet.getRatio(resource);
                if( val > 0 ) {
                    ratio.Text = val.ToString() + "%";
                } else {
                    ratio.Text = "-";
                }
            }

            Label perTurn = (Label) control.FindControl(resource + "PerTurn");
            if( perTurn != null ) {
                perTurn.EnableViewState = false;
                int val = planet.getPerTurn("Intrinsic",resource);
                string str = val.ToString();

                if( val > 0 ) {
                    str = "+" + str;
                    perTurn.Text = str;
                } else if( val == 0 ) {
                    perTurn.Text = "-";
                } else {
                    perTurn.CssClass = "error";
                    perTurn.Text = str;
                }
            }
        }
Example #28
0
 protected Control RecursiveFindControl(Control namingcontainer, string controlName)
 {
     Control control = namingcontainer.FindControl(controlName);
     if (control != null)
     {
         return control;
     }
     if (namingcontainer.NamingContainer != null)
     {
         return this.RecursiveFindControl(namingcontainer.NamingContainer, controlName);
     }
     return null;
 }
Example #29
0
 public static void IsChanged(ref bool yn, ref string strEditMess, Control parcontrol, Control control, bool IsSaveTitle, Page page)
 {
     if ((control.ID != null) && (control.ID.IndexOf("_bak") > 0))
     {
         string text = "";
         if (IsSaveTitle)
         {
             string str2 = "lab" + control.ID.Remove(0, 3);
             Label label = (Label) parcontrol.FindControl(str2.Replace("_bak", ""));
             if (label != null)
             {
                 text = label.Text;
             }
         }
         if (control is TextBox)
         {
             TextBox box = (TextBox) parcontrol.FindControl(control.ID.Replace("_bak", ""));
             TextBox box2 = (TextBox) control;
             if (((box != null) && (box2 != null)) && (box.Text != box2.Text))
             {
                 string str3 = strEditMess;
                 strEditMess = str3 + text + " 从 " + box2.Text + " 改为 " + box.Text + " ~ ";
                 yn = true;
             }
         }
         if (control is HtmlInputHidden)
         {
             HtmlInputHidden hidden = (HtmlInputHidden) parcontrol.FindControl(control.ID.Replace("_bak", ""));
             HtmlInputHidden hidden2 = (HtmlInputHidden) control;
             if (((hidden != null) && (hidden2 != null)) && (hidden.Value != hidden2.Value))
             {
                 string str4 = strEditMess;
                 strEditMess = str4 + text + " 从 " + hidden2.Value + " 改为 " + hidden.Value + " ~ ";
                 yn = true;
             }
         }
     }
 }
        private Control FindControl(Control toSearch, string idToFind)
        {
            Control c = toSearch.FindControl(idToFind);
            if (c == null && toSearch.Controls != null)
            {
                foreach (Control subControl in toSearch.Controls)
                {
                    c = FindControl(subControl, idToFind);
                    if (c != null) break;
                }
            }

            return c;
        }