---
title: clsNestedMaster
summary: API reference for clsNestedMaster.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics111
reference_type: package
---

# clsNestedMaster

`clsNestedMaster` is a stateless static helper that walks a chain of nested ASP.NET master pages, letting a control or page reach controls that live in an ancestor master rather than the immediate one, regardless of how deep the master-page nesting goes for a given consuming application.

## Purpose
- Count how many levels of master-page nesting exist above a given page (`MasterLevelCount`).
- Locate a specific ancestor master by level, or the outermost master (`FindMaster`, `Root`).
- Recursively locate a control that lives inside a named `ContentPlaceHolder` anywhere in the master chain, falling back to a direct search on the root master when the recursive search finds nothing. ([BR-CORE-035](../../business-rules.md#br-core-035-the-root-master-page-is-the-first-ancestor-master-with-no-parent-master), [BR-CORE-036](../../business-rules.md#br-core-036-control-search-within-nested-masters-is-scoped-to-the-named-content-placeholder-when-one-is-supplied), [BR-CORE-037](../../business-rules.md#br-core-037-if-the-recursive-nested-search-finds-nothing-a-direct-findcontrol-on-the-root-master-is-attempted))

## Context
- Namespace: `SAIF.Presentation.Web.Core`
- Assembly/package: `SAIF.Presentation.Web.Core.Infragistics111` (merged into `SAIF.Presentation.Web.Infragistics111.dll` via `SAIF.BOF.Presentation.Web.Infragistics111.nuspec`)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `MasterLevelCount(page)` | `Public Shared Function MasterLevelCount(page As Page) As Integer` | Recurses from `page.Master` upward, counting levels until a master with no parent master is reached; returns the total nesting depth. |
| `Root(page)` | `Public Shared Function Root(page As Page) As MasterPage` | Returns the outermost master page in the chain (equivalent to `FindMaster` at the maximum level). |
| `FindMaster(page, level)` | `Public Shared Function FindMaster(page As Page, Optional level As Integer = 1) As MasterPage` | Recurses to the requested ancestor level (default 1, meaning one level up from the immediate master) and returns that `MasterPage`. |
| `FindControl(page, controlID, contentPlaceHolderID)` | `Public Shared Function FindControl(page As Page, controlID As String, Optional contentPlaceHolderID As String = Nothing) As Control` | Starts from the root master and recursively walks the control tree, returning the first control found inside a `ContentPlaceHolder` whose `ID` matches `contentPlaceHolderID`; falls back to a direct `FindControl` on the root master if the recursive search finds nothing. |

## Behavioral notes
- All members are `Shared`, so `clsNestedMaster` holds no instance state and is safe to call concurrently from multiple pages/requests.*
- `FindControl`'s fallback to a direct root-master search means a control located at the top level (not nested inside the named content placeholder) can still be found even if the primary recursive search misses it.

## Constraints and usage notes
- If both the recursive search and the root-master fallback fail, `FindControl` returns `Nothing`; callers must guard against a null control reference.**

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `SAIF.Presentation.Web.Core.Infragistics111/clsNestedMaster.vb`
