System.Web.UI.Control.FindControl C# (CSharp) Method

FindControl() protected method

protected FindControl ( string id, int pathOffset ) : Control
id string
pathOffset int
return Control
		protected virtual Control FindControl (string id, int pathOffset)
		{
			EnsureChildControls ();
			Control namingContainer = null;
			if ((stateMask & IS_NAMING_CONTAINER) == 0) {
				namingContainer = NamingContainer;
				if (namingContainer == null)
					return null;
				
				return namingContainer.FindControl (id, pathOffset);
			}

			if (!HasControls ())
				return null;
			
			int separatorIdx = id.IndexOf (IdSeparator, pathOffset);
			if (separatorIdx == -1) {
				if (pathOffset == 0) {
					namingContainer = NamingContainer;
					if (namingContainer != null) {
						Control ctl = namingContainer.FindControl (id);
						if (ctl != null)
							return ctl;
					}
				}

				return LookForControlByName (pathOffset > 0 ? id.Substring (pathOffset) : id);
			}

			string idfound = id.Substring (pathOffset, separatorIdx - pathOffset);
			namingContainer = LookForControlByName (idfound);
			if (namingContainer == null)
				return null;

			return namingContainer.FindControl (id, separatorIdx + 1);
		}

Same methods

Control::FindControl ( string id ) : Control

Usage Example

Example #1
3
        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;
        }
All Usage Examples Of System.Web.UI.Control::FindControl