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
ContentPlaceHolderanywhere in the master chain, falling back to a direct search on the root master when the recursive search finds nothing. (BR-CORE-035, BR-CORE-036, BR-CORE-037)
Context¶
- Namespace:
SAIF.Presentation.Web.Core - Assembly/package:
SAIF.Presentation.Web.Core.Infragistics111(merged intoSAIF.Presentation.Web.Infragistics111.dllviaSAIF.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, soclsNestedMasterholds 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,
FindControlreturnsNothing; 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