C# Class Rock.Web.UI.RockPage

RockPage is the base abstract class that all page templates in Rock should inherit from
Inheritance: System.Web.UI.Page
显示文件 Open project: SparkDevNetwork/Rock Class Usage Examples

Protected Properties

Property Type Description
UserName string

Private Properties

Property Type Description
AddBlockMove void
AddGoogleAnalytics void
AddPopupControls void
AddTriggerPanel void
AddZoneElements void
GetCookieContext void
HtmlLinkExists bool
HtmlMetaExists bool
OnBlockUpdated void
SaveContextItem void
SetPage void

Public Methods

Method Description
AddCSSLink ( Page page, string href, bool fingerprint = true ) : void

Adds a new CSS link that will be added to the page header prior to the page being rendered

AddCSSLink ( Page page, string href, string mediaType, bool fingerprint = true ) : void

Adds the CSS link to the page

AddCSSLink ( string href, bool fingerprint = true ) : void

Adds a new CSS link that will be added to the page header prior to the page being rendered

AddCSSLink ( string href, string mediaType, bool fingerprint = true ) : void

Adds the CSS link to the page

AddConfigurationUpdateTrigger ( UpdatePanel updatePanel ) : void

Adds an update trigger for when the block instance properties are updated.

AddHistory ( string key, string state, string title = "" ) : void

Adds a history point to the ScriptManager. Note: ScriptManager's EnableHistory property must be set to True

AddHtmlLink ( System.Web.UI.HtmlControls.HtmlLink htmlLink ) : void

Adds a new Html link that will be added to the page header prior to the page being rendered.

AddHtmlLink ( Page page, System.Web.UI.HtmlControls.HtmlLink htmlLink, string contentPlaceHolderId = "" ) : void

Adds a new Html link that will be added to the page header prior to the page being rendered

AddMetaTag ( System.Web.UI.HtmlControls.HtmlMeta htmlMeta ) : void

Adds a meta tag to the page header prior to the page being rendered

AddMetaTag ( Page page, System.Web.UI.HtmlControls.HtmlMeta htmlMeta ) : void

Adds a meta tag to the page

AddScriptLink ( Page page, string path, bool fingerprint = true ) : void

Adds a new script tag to the page header prior to the page being rendered

AddScriptLink ( string path, bool fingerprint = true ) : void

Adds a new script tag to the page header prior to the page being rendered.

AddScriptToHead ( Page page, string script, bool AddScriptTags ) : void

Adds the script to head.

DeleteUserPreference ( string key ) : void

Deletes a user preference value for the specified key

GetAttributeValue ( string key ) : string

Returns the current page's first value for the selected attribute If the attribute doesn't exist, null is returned

GetAttributeValues ( string key ) : List

Returns the current page's values for the selected attribute. If the attribute doesn't exist an empty list is returned.

GetClientIpAddress ( ) : string

Gets the client's ip address.

GetContextCookieName ( bool pageSpecific ) : string

Gets the name of the context cookie.

GetContextEntityTypes ( ) : List

Gets the context entity types.

GetCurrentContext ( Rock.Web.Cache.EntityTypeCache entity ) : Rock.Data.IEntity

Gets the current context object for a given entity type.

GetSharedItem ( string key ) : object

Retrieves an item from the current HTTPRequest items collection. This is useful to retrieve an object that was saved by a previous block on the same page.

GetUserPreference ( string key ) : string

Returns a user preference for the current user and given key.

GetUserPreferences ( string keyPrefix ) : string>.Dictionary

Returns the preference values for the current user that start with a given key.

HideSecondaryBlocks ( Rock.Web.UI.RockBlock caller, bool hidden ) : void

Hides any secondary blocks.

LoadGoogleMapsApi ( ) : void

Adds the google maps javascript API to the page

LogException ( Exception ex ) : void

Logs the exception.

PageParameter ( Rock.Web.UI.PageReference pageReference, string name ) : string

Checks the page reference's parms and querystring for a parameter matching the specified name, and if found returns the string

PageParameter ( string name, bool searchFormParams = false ) : string

Checks the page's RouteData values and then the query string for a parameter matching the specified name, and if found returns the string value

PageParameters ( ) : object>.Dictionary

Gets the page route and query string parameters

ResolveRockUrl ( string url ) : string

Returns a resolved Rock URL. Similar to System.Web.UI.Control's ResolveUrl method except that you can prefix a url with '~~' to indicate a virtual path to Rock's current theme root folder.

ResolveRockUrl ( string url, bool fingerprint ) : string

Resolves the rock URL.

ResolveRockUrlIncludeRoot ( string url ) : string

Resolves the rock URL and includes root.

SaveSharedItem ( string key, object item ) : void

Used to save an item to the current HTTPRequests items collection. This is useful if multiple blocks on the same page will need access to the same object. The first block can read the object and save it using this method for the other blocks to reference

SaveUserPreferences ( string keyPrefix ) : void

Saves the user preferences.

SessionUserPreferences ( ) : string>.Dictionary

Returns the current user's preferences, if they have previously been loaded into the session, they will be retrieved from there, otherwise they will be retrieved from the database, added to session and then returned

SetContextCookie ( IEntity entity, bool pageSpecific = false, bool refreshPage = true ) : void

Sets the context cookie.

SetUserPreference ( string key, string value, bool saveValue = true ) : void

Sets a user preference value for the specified key. If the key already exists, the value will be updated, if it is a new key it will be added. Value is then optionally saved to database.

UpdateBlocks ( string blockTypePath ) : void

Updates the blocks.

Protected Methods

Method Description
FindRockControls ( System.Web.UI.ControlCollection controls ) : void

Recurses the page's System.Web.UI.ControlCollection looking for any Rock.Web.UI.Controls.Zone controls

FindZone ( string zoneName ) : Control

Find the Rock.Web.UI.Controls.Zone for the specified zone name. Looks in the Zones property to see if it has been defined. If an existing zone Rock.Web.UI.Controls.Zone cannot be found, the HtmlForm control is returned

InitializeCulture ( ) : void

Initializes the page's culture to use the culture specified by the browser ("auto")

OnInit ( EventArgs e ) : void

Loads all of the configured blocks for the current page into the control tree

OnLoad ( EventArgs e ) : void

Raises the E:System.Web.UI.Control.Load event.

OnSaveStateComplete ( EventArgs e ) : void

Raises the E:System.Web.UI.Page.SaveStateComplete event after the page state has been saved to the persistence medium.

scriptManager_Navigate ( object sender, System.Web.UI.HistoryEventArgs e ) : void

Handles the Navigate event of the scriptManager control.

trigger_Click ( object sender, EventArgs e ) : void

Handles the Click event of the trigger control.

Private Methods

Method Description
AddBlockMove ( ) : void

Adds a control to move the block to another zone on the page.

AddGoogleAnalytics ( string code ) : void

Adds the google analytics script

AddPopupControls ( ) : void

Adds the popup controls.

AddTriggerPanel ( ) : void

Adds the config elements.

AddZoneElements ( bool canConfigPage ) : void

Adds the config elements.

GetCookieContext ( string cookieName ) : void
HtmlLinkExists ( Control parentControl, System.Web.UI.HtmlControls.HtmlLink newLink ) : bool

Returns a System.Boolean flag indicating if a specified parent control contains the specified HtmlLink.

HtmlMetaExists ( Page page, System.Web.UI.HtmlControls.HtmlMeta newMeta ) : bool

Returns a flag indicating if a meta tag exists on the page.

OnBlockUpdated ( int blockId ) : void

Called when a block's properties are updated.

SaveContextItem ( string key, object item ) : void
SetPage ( PageCache pageCache ) : void

Sets the page.

Method Details

AddCSSLink() public static method

Adds a new CSS link that will be added to the page header prior to the page being rendered
public static AddCSSLink ( Page page, string href, bool fingerprint = true ) : void
page System.Web.UI.Page The .
href string A representing the path to css file. Should be relative to layout template. Will be resolved at runtime
fingerprint bool if set to true [fingerprint].
return void

AddCSSLink() public static method

Adds the CSS link to the page
public static AddCSSLink ( Page page, string href, string mediaType, bool fingerprint = true ) : void
page System.Web.UI.Page The .
href string A representing the path to css file. Should be relative to layout template. Will be resolved at runtime
mediaType string A representing the type of the media to use for the css link.
fingerprint bool if set to true [fingerprint].
return void

AddCSSLink() public method

Adds a new CSS link that will be added to the page header prior to the page being rendered
public AddCSSLink ( string href, bool fingerprint = true ) : void
href string A representing the path to css file. Should be relative to layout template. Will be resolved at runtime.
fingerprint bool if set to true [fingerprint].
return void

AddCSSLink() public method

Adds the CSS link to the page
public AddCSSLink ( string href, string mediaType, bool fingerprint = true ) : void
href string A representing the path to css file. Should be relative to layout template. Will be resolved at runtime
mediaType string A representing the type of the media to use for the css link.
fingerprint bool if set to true [fingerprint].
return void

AddConfigurationUpdateTrigger() public method

Adds an update trigger for when the block instance properties are updated.
public AddConfigurationUpdateTrigger ( UpdatePanel updatePanel ) : void
updatePanel System.Web.UI.UpdatePanel The to add the to.
return void

AddHistory() public method

Adds a history point to the ScriptManager. Note: ScriptManager's EnableHistory property must be set to True
public AddHistory ( string key, string state, string title = "" ) : void
key string A representing the key to use for the history point.
state string A representing any state information to store for the history point.
title string A representing the title to be used by the browser, will use an empty string by default.
return void

AddHtmlLink() public method

Adds a new Html link that will be added to the page header prior to the page being rendered.
public AddHtmlLink ( System.Web.UI.HtmlControls.HtmlLink htmlLink ) : void
htmlLink System.Web.UI.HtmlControls.HtmlLink The .
return void

AddHtmlLink() public static method

Adds a new Html link that will be added to the page header prior to the page being rendered
public static AddHtmlLink ( Page page, System.Web.UI.HtmlControls.HtmlLink htmlLink, string contentPlaceHolderId = "" ) : void
page System.Web.UI.Page The .
htmlLink System.Web.UI.HtmlControls.HtmlLink The to add to the page.
contentPlaceHolderId string A representing the Id of the content placeholder to add the link to.
return void

AddMetaTag() public method

Adds a meta tag to the page header prior to the page being rendered
public AddMetaTag ( System.Web.UI.HtmlControls.HtmlMeta htmlMeta ) : void
htmlMeta System.Web.UI.HtmlControls.HtmlMeta The tag.
return void

AddMetaTag() public static method

Adds a meta tag to the page
public static AddMetaTag ( Page page, System.Web.UI.HtmlControls.HtmlMeta htmlMeta ) : void
page System.Web.UI.Page The .
htmlMeta System.Web.UI.HtmlControls.HtmlMeta A representing the HTML meta tag.
return void

AddScriptLink() public static method

Adds a new script tag to the page header prior to the page being rendered
public static AddScriptLink ( Page page, string path, bool fingerprint = true ) : void
page System.Web.UI.Page The .
path string A representing the path to script file. Should be relative to layout template. Will be resolved at runtime.
fingerprint bool if set to true [fingerprint].
return void

AddScriptLink() public method

Adds a new script tag to the page header prior to the page being rendered.
public AddScriptLink ( string path, bool fingerprint = true ) : void
path string A representing the path to the script link.
fingerprint bool if set to true [fingerprint].
return void

AddScriptToHead() public static method

Adds the script to head.
public static AddScriptToHead ( Page page, string script, bool AddScriptTags ) : void
page System.Web.UI.Page The page.
script string The script.
AddScriptTags bool if set to true [add script tags].
return void

DeleteUserPreference() public method

Deletes a user preference value for the specified key
public DeleteUserPreference ( string key ) : void
key string A representing the name of the key.
return void

FindRockControls() protected method

Recurses the page's System.Web.UI.ControlCollection looking for any Rock.Web.UI.Controls.Zone controls
protected FindRockControls ( System.Web.UI.ControlCollection controls ) : void
controls System.Web.UI.ControlCollection A containing the page's controls.
return void

FindZone() protected method

Find the Rock.Web.UI.Controls.Zone for the specified zone name. Looks in the Zones property to see if it has been defined. If an existing zone Rock.Web.UI.Controls.Zone cannot be found, the HtmlForm control is returned
protected FindZone ( string zoneName ) : Control
zoneName string A representing the name of the zone.
return System.Web.UI.Control

GetAttributeValue() public method

Returns the current page's first value for the selected attribute If the attribute doesn't exist, null is returned
public GetAttributeValue ( string key ) : string
key string A representing the argument key.
return string

GetAttributeValues() public method

Returns the current page's values for the selected attribute. If the attribute doesn't exist an empty list is returned.
public GetAttributeValues ( string key ) : List
key string A representing the key of the selected attribute ///
return List

GetClientIpAddress() public static method

Gets the client's ip address.
public static GetClientIpAddress ( ) : string
return string

GetContextCookieName() public method

Gets the name of the context cookie.
public GetContextCookieName ( bool pageSpecific ) : string
pageSpecific bool if set to true [page specific].
return string

GetContextEntityTypes() public method

Gets the context entity types.
public GetContextEntityTypes ( ) : List
return List

GetCurrentContext() public method

Gets the current context object for a given entity type.
public GetCurrentContext ( Rock.Web.Cache.EntityTypeCache entity ) : Rock.Data.IEntity
entity Rock.Web.Cache.EntityTypeCache The containing a reference to the entity.
return Rock.Data.IEntity

GetSharedItem() public method

Retrieves an item from the current HTTPRequest items collection. This is useful to retrieve an object that was saved by a previous block on the same page.
public GetSharedItem ( string key ) : object
key string A representing the object's key value.
return object

GetUserPreference() public method

Returns a user preference for the current user and given key.
public GetUserPreference ( string key ) : string
key string A representing the key to the user preference.
return string

GetUserPreferences() public method

Returns the preference values for the current user that start with a given key.
public GetUserPreferences ( string keyPrefix ) : string>.Dictionary
keyPrefix string A representing the key prefix. Preference values, for the current user, with a key that begins with this value will be included.
return string>.Dictionary

HideSecondaryBlocks() public method

Hides any secondary blocks.
public HideSecondaryBlocks ( Rock.Web.UI.RockBlock caller, bool hidden ) : void
caller Rock.Web.UI.RockBlock The that is the caller
hidden bool A value that signifies if secondary blocks should be hidden.
return void

InitializeCulture() protected method

Initializes the page's culture to use the culture specified by the browser ("auto")
protected InitializeCulture ( ) : void
return void

LoadGoogleMapsApi() public method

Adds the google maps javascript API to the page
public LoadGoogleMapsApi ( ) : void
return void

LogException() public method

Logs the exception.
public LogException ( Exception ex ) : void
ex System.Exception The to log.
return void

OnInit() protected method

Loads all of the configured blocks for the current page into the control tree
protected OnInit ( EventArgs e ) : void
e System.EventArgs
return void

OnLoad() protected method

Raises the E:System.Web.UI.Control.Load event.
protected OnLoad ( EventArgs e ) : void
e System.EventArgs The object that contains the event data.
return void

OnSaveStateComplete() protected method

Raises the E:System.Web.UI.Page.SaveStateComplete event after the page state has been saved to the persistence medium.
protected OnSaveStateComplete ( EventArgs e ) : void
e System.EventArgs A object containing the event data.
return void

PageParameter() public method

Checks the page reference's parms and querystring for a parameter matching the specified name, and if found returns the string
public PageParameter ( Rock.Web.UI.PageReference pageReference, string name ) : string
pageReference Rock.Web.UI.PageReference The .
name string A containing the name of the parameter.
return string

PageParameter() public method

Checks the page's RouteData values and then the query string for a parameter matching the specified name, and if found returns the string value
public PageParameter ( string name, bool searchFormParams = false ) : string
name string A representing the name of the page parameter.
searchFormParams bool if set to true [search form parameters].
return string

PageParameters() public method

Gets the page route and query string parameters
public PageParameters ( ) : object>.Dictionary
return object>.Dictionary

ResolveRockUrl() public method

Returns a resolved Rock URL. Similar to System.Web.UI.Control's ResolveUrl method except that you can prefix a url with '~~' to indicate a virtual path to Rock's current theme root folder.
public ResolveRockUrl ( string url ) : string
url string A representing the URL to resolve.
return string

ResolveRockUrl() public method

Resolves the rock URL.
public ResolveRockUrl ( string url, bool fingerprint ) : string
url string The URL.
fingerprint bool if set to true [fingerprint].
return string

ResolveRockUrlIncludeRoot() public method

Resolves the rock URL and includes root.
public ResolveRockUrlIncludeRoot ( string url ) : string
url string The URL.
return string

SaveSharedItem() public method

Used to save an item to the current HTTPRequests items collection. This is useful if multiple blocks on the same page will need access to the same object. The first block can read the object and save it using this method for the other blocks to reference
public SaveSharedItem ( string key, object item ) : void
key string A representing the item's key
item object The to save.
return void

SaveUserPreferences() public method

Saves the user preferences.
public SaveUserPreferences ( string keyPrefix ) : void
keyPrefix string The key prefix.
return void

SessionUserPreferences() public method

Returns the current user's preferences, if they have previously been loaded into the session, they will be retrieved from there, otherwise they will be retrieved from the database, added to session and then returned
public SessionUserPreferences ( ) : string>.Dictionary
return string>.Dictionary

SetContextCookie() public method

Sets the context cookie.
public SetContextCookie ( IEntity entity, bool pageSpecific = false, bool refreshPage = true ) : void
entity IEntity The entity.
pageSpecific bool if set to true [page specific].
refreshPage bool if set to true [refresh page].
return void

SetUserPreference() public method

Sets a user preference value for the specified key. If the key already exists, the value will be updated, if it is a new key it will be added. Value is then optionally saved to database.
public SetUserPreference ( string key, string value, bool saveValue = true ) : void
key string A representing the name of the key.
value string A representing the preference value.
saveValue bool if set to true [save value].
return void

UpdateBlocks() public method

Updates the blocks.
public UpdateBlocks ( string blockTypePath ) : void
blockTypePath string The block type path.
return void

scriptManager_Navigate() protected method

Handles the Navigate event of the scriptManager control.
protected scriptManager_Navigate ( object sender, System.Web.UI.HistoryEventArgs e ) : void
sender object The source of the event.
e System.Web.UI.HistoryEventArgs The instance containing the event data.
return void

trigger_Click() protected method

Handles the Click event of the trigger control.
protected trigger_Click ( object sender, EventArgs e ) : void
sender object The source of the event.
e System.EventArgs The instance containing the event data.
return void

Property Details

UserName protected_oe property

The full name of the currently logged in user
protected string UserName
return string