Skip to content

ViewPageBase

ViewPageBase is the WebForms page base class every SAIF screen derives from. It wires the screen's clsFactoryBase-produced controller into the ASP.NET page lifecycle (Page_Init calls Initialize, Page_Load harvests posted control values via CallRetrieve, Page_Unload calls UnInitialize), owns the per-view identity (ViewID, backed by the __SAIFPID hidden field/query string) that keys multi-model session state, decides whether view state is persisted in the page or moved into session, restores keyboard focus to the last-bound control through its nested NavigationManager, and is the entry point for Page error processing. It intentionally contains no business logic — that lives in the derived screen and its clsControllerBase/clsModelBase pair.

Purpose

  • Wires a screen's controller into the ASP.NET page lifecycle so Initialize, CallRetrieve, and UnInitialize run automatically on every request.
  • Owns the per-view identifier (ViewID) that partitions model/view-data session state for multi-model (multi-window) screens (BR-MVC-008).
  • Selects between standard ViewState and session-backed view state depending on the ViewStateInSession setting and the EXT_VIEWSTATE_SESSION configuration key (BR-MVC-030).
  • Provides the single page-level error entry point (ProcessError), delegating to Page error processing.
  • Restores keyboard focus to the last-bound control via its nested NavigationManager (Restore input focus, BR-MVC-027).

Context

  • Namespace: SAIF.Presentation.Web.MVC*
  • Assembly/package: SAIF.Presentation.Web.MVC

The markup files reference Inherits="SAIF.ViewPageBase" with no explicit Namespace statement in code; the namespace shown here follows the project's RootNamespace (SAIF.Presentation.Web.MVC), consistent with sibling libraries in this repository. The markup-declared namespace could not be independently confirmed.*

Public members

Member Signature Purpose
SAIFPID_NAME Public Const SAIFPID_NAME As String = "__SAIFPID" The hidden-field/query-string/session key name used to carry the current view's GUID identifier across postbacks and cross-application navigation
MessageControl Public Property MessageControl() As Label The label control error/status text is written to; lazily instantiates a new Label if the derived page never set one
PageMode Public Property PageMode() As PageModeEnum The current view/update/insert/delete/print/PDF mode for this page instance, held in ViewState
ViewStateInSession Public Property ViewStateInSession() As VIEWSTATE_CTRL_ENUM Opt-in switch that moves this page's view state into session storage instead of the rendered page, for external or all users
ViewID Public Property ViewID() As String (Friend setter) The per-view GUID identifier that keys this instance's model and view data in session when SupportsMultiModel is enabled; falls back to ApplicationName otherwise (BR-MVC-008)
ProcessError Protected Friend Sub ProcessError(ByVal ex As Exception) Entry point for unhandled page exceptions; see Page error processing
HandleApplicationError Protected Friend Overridable Function HandleApplicationError(ByVal ex As Exception) As Boolean Derived-class hook; returning True tells the framework the application fully handled the exception, suppressing framework logging/routing (BR-MVC-022)
PageStatePersister Protected Overrides ReadOnly Property PageStatePersister() As System.Web.UI.PageStatePersister Overridden to return a SessionPageStatePersister when ViewStateInSession or the EXT_VIEWSTATE_SESSION setting requires it for the current caller, otherwise falls back to the base ASP.NET persister
PageModeEnum Public nested enum See ViewPageBase.PageModeEnum
VIEWSTATE_CTRL_ENUM Public nested enum See ViewPageBase.VIEWSTATE_CTRL_ENUM

Behavioral notes

  • Page_Init skips all controller wiring entirely when DesignMode is true, so design-time rendering never triggers Initialize.
  • ViewID's getter has three fallback sources in order: the posted __SAIFPID form field (handling a ;NEW suffix that triggers Navigate2), the session-stored __SAIFPID value, and finally CheckContextViewID() or a freshly generated Guid.
  • The nested NavigationManager and PageStatePersister override are exercised on every request regardless of page mode; PageStatePersister reads the EXT_VIEWSTATE_SESSION AppSettings key on every access rather than caching it.*

Constraints and usage notes

  • ViewID's setter is Friend, so only code within this assembly can reassign a page's view identity; derived screens read it but do not set it directly.
  • ProcessError rethrows immediately if m_controller is Nothing, so an exception occurring before the controller is constructed (e.g., inside Page_Init itself, before m_controller = m_factory.GetController) cannot be handled by this class and propagates to ASP.NET's default error handling.

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.MVC/ViewPageBase.aspx.vb