當前位置: 首頁>>代碼示例>>C#>>正文


C# Control.HasControls方法代碼示例

本文整理匯總了C#中System.Web.UI.Control.HasControls方法的典型用法代碼示例。如果您正苦於以下問題:C# Control.HasControls方法的具體用法?C# Control.HasControls怎麽用?C# Control.HasControls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.UI.Control的用法示例。


在下文中一共展示了Control.HasControls方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FindChildControl

 internal Control FindChildControl(string strid, Control ct)
 {
     if (ct.ID == strid)
     {
         return ct;
     }
     else
     {
         if (ct.HasControls())
         {
             foreach (Control ctchild in ct.Controls)
             {
                 Control ctrtn = FindChildControl(strid, ctchild);
                 if (ctrtn != null)
                 {
                     return ctrtn;
                 }
             }
             return null;
         }
         else
         {
             return null;
         }
     }
 }
開發者ID:san90279,項目名稱:UK_OAS,代碼行數:26,代碼來源:WebDetailsView.cs

示例2: ClearControls

        public static void ClearControls(ref Control control)
        {
            if (control == null)
                return;

            if (control is TextBox)
            {
                ((TextBox)control).Text = string.Empty;
                return;
            }

            else if (control is DropDownList)
            {
                ((DropDownList)control).SelectedIndex = 0;
                return;
            }

            if (control.HasControls())
            {
                foreach (Control c in control.Controls)
                {
                    Control ctrl = c;
                    ClearControls(ref ctrl);
                }
            }
        }
開發者ID:sunilbulusu,項目名稱:DealerSoftware,代碼行數:26,代碼來源:ControlManager.cs

示例3: GetWebValidateBox

 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;
     }
 }
開發者ID:san90279,項目名稱:UK_OAS,代碼行數:26,代碼來源:WebValidateBox.cs

示例4: ClearForm

        public static void ClearForm(Control container, FormClearOptions option, bool check_nc)
        {
            try
            {
                switch (option)
                {
                    case FormClearOptions.ClearAll:

                        if (check_nc)
                        {
                            if (container.ID != null)
                                if (container.ID.EndsWith("_nc"))
                                    break;
                        }

                        if (container.GetType().Equals(typeof(TextBox)))
                        {
                            TextBox txtBox = ((TextBox)container);
                            txtBox.Text = string.Empty;
                        }
                        else if (container.GetType().Equals(typeof(DropDownList)))
                        {
                            DropDownList ddl = ((DropDownList)container);
                            ddl.SelectedValue = string.Empty;
                        }
                        else if (container.GetType().Equals(typeof(CheckBox)))
                        {
                            CheckBox chk = ((CheckBox)container);
                            chk.Checked = false;
                        }
                        else if (container.GetType().Equals(typeof(RadioButtonList)))
                        {
                            RadioButtonList rbl = ((RadioButtonList)container);
                            rbl.SelectedIndex = -1;
                        }
                        else if (container.GetType().Equals(typeof(RadioButton)))
                        {
                            RadioButton rb = ((RadioButton)container);
                            rb.Checked = false;
                        }
                        else if (container.HasControls())
                        {
                            foreach (Control ctrl in container.Controls)
                                ClearForm(ctrl, option, check_nc);
                        }
                        break;

                    default:
                        break;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
開發者ID:samnuriu13,項目名稱:APIXERP,代碼行數:57,代碼來源:formUtil.cs

示例5: Crawl

 private static string Crawl(Control objControl, int intLevel)
 {
     string result = new string('-',intLevel) + objControl.ClientID + "<br>";
     if(objControl.HasControls())
     {
         foreach(Control c in objControl.Controls)
             result += Crawl(c,intLevel + 1);
     }
     return result;
 }
開發者ID:AgentTy,項目名稱:General,代碼行數:10,代碼來源:ControlCrawler.cs

示例6: SetViewState

 public static void SetViewState(Control container)
 {
     container.ViewStateMode= ViewStateMode.Disabled;
     if (container.HasControls())
     {
         foreach(Control ctrl in container.Controls)
         {
             Control control = ctrl;
             SetViewState(control);
         }
     }
 }
開發者ID:sunilbulusu,項目名稱:DealerSoftware,代碼行數:12,代碼來源:ControlManager.cs

示例7: getAllPageControls

 /// <summary>
 /// Recursively gets every control of the specified root (including root and all it's child controls).
 /// Returns the controls as an array of Control objects.
 /// </summary>
 /// <param name="root">The root control to get child controls for.</param>
 /// <returns>An array of all the child controls of root.</returns>
 public static Control[] getAllPageControls(Control root)
 {
     List<Control> list = new List<Control>();
     list.Add(root);
     if (root.HasControls())
     {
         foreach (Control control in root.Controls)
         {
             list.AddRange(getAllPageControls(control));
         }
     }
     return list.ToArray();
 }
開發者ID:deuterium,項目名稱:comp4900project,代碼行數:19,代碼來源:Default.aspx.cs

示例8: FlattenHierachy

 public static Control[] FlattenHierachy(Control root)
 {
     List<Control> list = new List<Control>();
     list.Add(root);
     if (root.HasControls())
     {
         foreach (Control control in root.Controls)
         {
             list.AddRange(FlattenHierachy(control));
         }
     }
     return list.ToArray();
 }
開發者ID:akash073,項目名稱:Walton,代碼行數:13,代碼來源:WebForm1.aspx.cs

示例9: InjectDependenciesRecursiveInternal

        private static Control InjectDependenciesRecursiveInternal(IApplicationContext appContext, Control control)
        {
            if (control is LiteralControl) return control; // nothing to do

            ISupportsWebDependencyInjection diControl = control as ISupportsWebDependencyInjection;
            if (diControl != null && diControl.DefaultApplicationContext != null)
            {
                return control; // nothing to do anymore - control cares for itself and its children
            }

            // "intercept" Control to make it DI-aware
            ControlInterceptor.EnsureControlIntercepted(appContext, control);

            // if the control is a UserControl, use ApplicationContext from it's physical location
            IApplicationContext appContextToUse = appContext;
            UserControl userControl = control as UserControl;
            if (userControl != null)
            {
                appContextToUse = GetControlApplicationContext(appContext, userControl);
            }

            // set ApplicationContext instance
            if (control is IApplicationContextAware)
            {
                ((IApplicationContextAware)control).ApplicationContext = appContextToUse;
            }

            // inject dependencies using control's context
            control = (Control)appContextToUse.ConfigureObject(control, control.GetType().FullName);

            // and now go for control's children
            if (control.HasControls())
            {
                ControlCollection childControls = control.Controls;
                int childCount = childControls.Count;
                for (int i = 0; i < childCount; i++)
                {
                    Control c = childControls[i];
                    if (c is LiteralControl) continue;

                    Control configuredControl = InjectDependenciesRecursiveInternal(appContext, c);
                    if (configuredControl != c)
                    {
                        ControlAccessor ac = new ControlAccessor(c.Parent);
                        ac.SetControlAt(configuredControl, i);
                    }
                }
            }

            return control;
        }
開發者ID:fgq841103,項目名稱:spring-net,代碼行數:51,代碼來源:WebDependencyInjectionUtils.cs

示例10: FlattenHierachy

        /// <summary>
        /// Get all page controls, recursively, ignoring irrelevant controls.
        /// </summary>
        public static Control[] FlattenHierachy(Control root)
        {
            if (IgnoreControl(root)) return new Control[0];

            var list = new List<Control>() { root };

            if (root.HasControls())
            {
                foreach (Control c in root.Controls)
                {
                    list.AddRange(FlattenHierachy(c));
                }
            }

            return list.ToArray();
        }
開發者ID:wagnerandrade,項目名稱:MisterPostman,代碼行數:19,代碼來源:PostmanActivator.cs

示例11: HookOnFocus

 public void HookOnFocus(Control CurrentControl)
 {
     //checks if control is one of TextBox, DropDownList, ListBox or Button
     if ((CurrentControl is TextBox) ||
         (CurrentControl is DropDownList) ||
         (CurrentControl is ListBox) ||
         (CurrentControl is Button))
         //adds a script which saves active control on receiving focus
         //in the hidden field __LASTFOCUS.
         (CurrentControl as WebControl).Attributes.Add(
            "onfocus",
            "try{document.getElementById('__LASTFOCUS').value=this.id} catch(e) {}");
     //checks if the control has children
     if (CurrentControl.HasControls())
         //if yes do them all recursively
         foreach (Control CurrentChildControl in CurrentControl.Controls)
             HookOnFocus(CurrentChildControl);
 }
開發者ID:saadzaman,項目名稱:myProject,代碼行數:18,代碼來源:BasePages.cs

示例12: HasNoControls

 /// <summary>
 /// Verifies that <paramref name="ctrl"/> has no child controls.
 /// </summary>
 public static void HasNoControls(Control ctrl)
 {
     Assert.IsNotNull(ctrl);
     Assert.IsFalse(ctrl.HasControls(),
                   "Control {0} has child controls",
                   ctrl.ID);
 }
開發者ID:BackupTheBerlios,項目名稱:mbunit-svn,代碼行數:10,代碼來源:WebAssert.cs

示例13: FindByType

		Control FindByType (Control parent, Type type)
		{
			if (!parent.HasControls ())
				return null;

			foreach (Control c in parent.Controls) {
				if (type.IsAssignableFrom (c.GetType ()))
					return c;

				Control ret = FindByType (c, type);
				if (ret != null)
					return ret;
			}
			return null;
		}
開發者ID:JokerMisfits,項目名稱:linux-packaging-mono,代碼行數:15,代碼來源:DataGridTest.cs

示例14: findControl

 private Control findControl(Control parent, string id)
 {
     if (parent.HasControls())
     {
         Control control = parent.FindControl(id);
         if (control != null)
         {
             return control;
         }
         foreach (Control control2 in parent.Controls)
         {
             control = this.findControl(control2, id);
             if (control != null)
             {
                 return control;
             }
         }
     }
     return null;
 }
開發者ID:chutinhha,項目名稱:tvmcorptvs,代碼行數:20,代碼來源:PageHeadDelegateControl.cs

示例15: HasControls

 /// <summary>
 /// Verifies that <paramref name="ctrl"/> has child controls.
 /// </summary>		
 public static void HasControls(Control ctrl)
 {
     Assert.IsNotNull(ctrl);
     Assert.IsTrue(ctrl.HasControls(),
                   "Control {0} has no controls",
                   ctrl.ID);
 }
開發者ID:BackupTheBerlios,項目名稱:mbunit-svn,代碼行數:10,代碼來源:WebAssert.cs


注:本文中的System.Web.UI.Control.HasControls方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。