当前位置: 首页>>代码示例>>C#>>正文


C# Control.FindControl方法代码示例

本文整理汇总了C#中Control.FindControl方法的典型用法代码示例。如果您正苦于以下问题:C# Control.FindControl方法的具体用法?C# Control.FindControl怎么用?C# Control.FindControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Control的用法示例。


在下文中一共展示了Control.FindControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindControl

        /// <devdoc>
        /// Walks up the stack of NamingContainers starting at 'control' to find a control with the ID 'controlID'.
        /// Important : Note that the search is never done on the 'control' itself by this method.
        /// </devdoc>
        public static Control FindControl(Control control, string controlID) {
            Debug.Assert(control != null, "control should not be null");
            Debug.Assert(!String.IsNullOrEmpty(controlID), "controlID should not be empty");
            Control currentContainer = control;
            Control foundControl = null;

            if (control == control.Page) {
                // If we get to the Page itself while we're walking up the
                // hierarchy, just return whatever item we find (if anything)
                // since we can't walk any higher.
                return control.FindControl(controlID);
            }

            while (foundControl == null && currentContainer != control.Page) {
                currentContainer = currentContainer.NamingContainer;
                if (currentContainer == null) {
                    throw new HttpException(SR.GetString(SR.DataBoundControlHelper_NoNamingContainer, control.GetType().Name, control.ID));
                }
                foundControl = currentContainer.FindControl(controlID);
            }

            return foundControl;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:27,代码来源:DataBoundControlHelper.cs

示例2: FindPlaceholder

 protected virtual Control FindPlaceholder(string containerID, Control container) {
     return container.FindControl(containerID);
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:3,代码来源:ListView.cs


注:本文中的Control.FindControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。