本文整理汇总了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;
}
示例2: FindPlaceholder
protected virtual Control FindPlaceholder(string containerID, Control container) {
return container.FindControl(containerID);
}