Table of Contents

Class PageView

Namespace
Dynamicweb.Frontend
Assembly
Dynamicweb.dll
The pageview object represents the current frontend pageview, the object that handles Default.aspx and all frontend page views.
public class PageView
Inheritance
PageView
Inherited Members

Examples

//Get current instance
    Dynamicweb.Frontend.PageView pv = Dynamicweb.Frontend.PageView.Current();

    Change properties on the PageView object
    pv.Meta.Title = "New title";
'Get current instance
    Dim pv As Dynamicweb.Frontend.PageView = Dynamicweb.Frontend.PageView.Current

    'Change properties on the PageView object
    pv.Meta.Title = "New title"

Remarks

Use the PageView.Current to access the instance from any code block that is run in the pageview context.

Constructors

PageView()

Initializes a new instance of the PageView class.
public PageView()

Remarks

Use Current() or PageView.GetPageviewByPageID to get an instance.

Properties

Area

Gets the Area of the current Page being rendered.
public Area Area { get; }

Property Value

Area
The area.

AreaID

The ID of the Area or website of this instance of pageview object.
public int AreaID { get; set; }

Property Value

int

AreaSettings

Gets an ItemViewModel instance of this pageviews area setting item.
public ItemViewModel AreaSettings { get; }

Property Value

ItemViewModel

Remarks

Returns null until the Load() method has been executed.

BeforeBodyEndMarkup

String in this property is inserted before the pageview is outputted - string is inserted just before the closing body tag.
public StringBuilder BeforeBodyEndMarkup { get; set; }

Property Value

StringBuilder

Remarks

Can be used to insert script tags before the body tag. If no closing body tag is available, the string is not inserted NOTE: Do not override this variable. Add your string to the current value.

CdnHostName

Gets the name of the CDN hostname from the website settings or global settings.
public string CdnHostName { get; }

Property Value

string
The name of the CDN host.

CdnHostNameForGetImage

[Obsolete("Use CdnHostnameForImage instead.")]
public string CdnHostNameForGetImage { get; }

Property Value

string

CdnHostNameForImage

Gets the name of the CDN GetImage hostname from the website settings or global settings.
public string CdnHostNameForImage { get; }

Property Value

string
The CDN host name for get image.

Context

public PageViewContext Context { get; set; }

Property Value

PageViewContext

CurrentParagraph

Gets the current paragraph being rendered.
public Paragraph CurrentParagraph { get; }

Property Value

Paragraph
Will be null if a paragraph is not being rendered.

Remarks

Should only be used from objects in the context of a paragraph. I.e. a paragraph template extender, product template extender or content module.

Device

Gets the DeviceType of the current request based on the User agent string of the browser.
public DeviceType Device { get; }

Property Value

DeviceType

Execution

Gets the ExecutionTable of the pageview. Used internally to measure time spend on renderers.
public ExecutionTable Execution { get; set; }

Property Value

ExecutionTable

Remarks

Should not be used.

ExperimentTracker

Gets the experiment tracker if this page has a split test experiment available.
[Obsolete("Do not use")]
public IExperiment ExperimentTracker { get; }

Property Value

IExperiment

ExperimentVariation

Gets the experiment variation of this pageview if the page has experiments.
public int ExperimentVariation { get; }

Property Value

int

Remarks

If page does not have experiments, 0 is returned. If original needs to be show, 1 is returned. Otherwise the ID of the variation

GlobalTags

Gets a collection of the global tags available for this pageview instance.
public TagCollection GlobalTags { get; }

Property Value

TagCollection
The global tags collection in a TagCollection.

Remarks

Used from Razor templates to get access to Global tags. Should not be used in context of a layout using the PageViewModel instance to render.

HtmlVersion

Gets the HTML version. Can be either html4, xhtml1 and html5. Influences the rendering of image tags, tables in form modules and other html version specific rules.
public PageView.HtmlType HtmlVersion { get; }

Property Value

PageView.HtmlType
The HTML version.

Remarks

This property is set on the websites properties from the administration. Not set until PageView.Load have been executed.

ID

Page ID of this instance of pageview object.
public int ID { get; set; }

Property Value

int

IsCurrentUserAllowed

public bool IsCurrentUserAllowed { get; }

Property Value

bool

IsCurrentUserPasswordAllowed

public bool IsCurrentUserPasswordAllowed { get; set; }

Property Value

bool

IsCurrentUserPermissionAllowed

public bool IsCurrentUserPermissionAllowed { get; set; }

Property Value

bool

IsEmailContext

Gets or sets a value indicating whether this instance is email context.
public bool IsEmailContext { get; set; }

Property Value

bool
true if this instance is in the context of sending out an email; otherwise, false.

Remarks

Used by Email marketing to send out pages as email.

IsVisualEditorMode

public bool IsVisualEditorMode { get; }

Property Value

bool

Item

Gets the instance of Item of the current page.
public Item Item { get; }

Property Value

Item
The item.

Layout

Gets the layout of this pageview.
public Layout Layout { get; }

Property Value

Layout
The layout.

Remarks

This layout template is set on the page or website properties from the administration. Not set until PageView.Load have been executed.

Meta

Gets the Meta instance of the current pageview object.
public Meta Meta { get; set; }

Property Value

Meta

Page

Gets the Page being rendered in the instance of this pageview.
public Page Page { get; }

Property Value

Page
The page.

Platform

Gets the PlatformType of the current request based on the User agent string of the browser.
public PlatformType Platform { get; }

Property Value

PlatformType

Redirect

Gets or sets a value indicating whether this PageView are allowed to do redirect.
public bool Redirect { get; set; }

Property Value

bool
true if redirects are allowed; otherwise, false.

Remarks

If this property is set to false, Dynamicweb will not redirect to i.e. search friendly url version of the same page. Use PageView.GetPageviewByPageID to get an instance that does not redirect.

SearchFriendlyUrl

Gets the search friendly URL for this instance of the pageview.
public string SearchFriendlyUrl { get; }

Property Value

string
The search friendly URL for the page currently being showed.

Remarks

The returned URL will contain any querystring information on the original url.

Security

Gets the security object which handles extranet functionality.
[Obsolete("Use SecurityHandler instead.")]
public LoginHandler Security { get; set; }

Property Value

LoginHandler

Remarks

Use this to access information on the current logged in user

SecurityHandler

Gets the object which handles extranet functionality.
public SecurityHandler SecurityHandler { get; set; }

Property Value

SecurityHandler

Remarks

Use this to access information on the current logged in user.

Template

Gets the instance of the template object of the layout template.
public Template Template { get; }

Property Value

Template

Remarks

Will be null until the Load() has been called.

User

Gets the extranet user currently logged into the frontend.
public User User { get; }

Property Value

User

Remarks

If no user is logged in, null is returned

Methods

AddJavascript(string)

Adds a javascript path to the pages scripts section in head.
public void AddJavascript(string javascript)

Parameters

javascript string
The javascript path reference.

Examples

Dynamicweb.Frontend.PageView.Current().AddJavascript("/Files/System/Myjs.js");
Dynamicweb.Frontend.PageView.Current.AddJavascript("/Files/System/Myjs.js")

AddStylesheet(string)

Adds a stylesheet path to the pages stylesheets section in head.
public void AddStylesheet(string stylesheet)

Parameters

stylesheet string
The stylesheet path reference.

Examples

Dynamicweb.Frontend.PageView.Current().AddStylesheet("/Files/System/MyCss.css");
Dynamicweb.Frontend.PageView.Current.AddStylesheet("/Files/System/MyCss.css")

AddStylesheet(string, string)

Adds a stylesheet path to the pages stylesheets section in head for a given media.
public void AddStylesheet(string stylesheet, string media)

Parameters

stylesheet string
The stylesheet reference.
media string
The media type. One of print, screen, tv, all or other valid css media type. Default is string.empty.

Examples

PageView.Current().AddStylesheet("/Files/System/MyCss.css", "print");
PageView.Current.AddStylesheet("/Files/System/MyCss.css", "print")

Current()

Gets the PageView object of the current pageview. This can only be called in a frontend context.
public static PageView Current()

Returns

PageView
Returns null or nothing if not called from frontend or prior to Pageview.Load event has occured

Examples

//Get current instance
    PageView pv = PageView.Current();
    Change properties on the PageView object
    pv.Meta.Title = "New title";
'Get current instance
    Dim pv As PageView = PageView.Current
    'Change properties on the PageView object
    pv.Meta.Title = "New title"

Remarks

Should only be called from code executed in frontend. Use PageView.GetPageviewByPageID from backend code.

GetAreaByDomain()

Gets an instance of an area by the domain name of the current request.
public static Area GetAreaByDomain()

Returns

Area
Dynamicweb.Content.Area.

Remarks

Uses the domain and primary domain information set on website properties to find the right area

GetAreaByDomain(string)

Gets an instance of an area by the paseed domain name.
public static Area GetAreaByDomain(string domain)

Parameters

domain string
The domain, i.e. 'www.dynamicweb.com'

Returns

Area
Dynamicweb.Content.Area.

Remarks

Uses the domain and primary domain information set on website properties to find the right area

GetAreasByDomain()

Gets areas by the domain name of the current request.
public static IEnumerable<Area> GetAreasByDomain()

Returns

IEnumerable<Area>
Dynamicweb.Content.Area.

Remarks

Uses the domain and primary domain information set on website properties to find the right area

GetContent()

Gets a collection of content for this pageview for each placeholder in the layout.
public IDictionary<string, string> GetContent()

Returns

IDictionary<string, string>
System.Collections.Generic.IDictionary(Of System.String, System.String). The collection contains a key (the id of the placeholder) and the resulting html of the rendered paragraphs in a content placeholder including module output.

GetFeedContent()

Gets a feed string coming from the content section of the pageview.
public string GetFeedContent()

Returns

string
A json string

GetPageview()

Retrieves a top-level pageview instance for use in backend context. Use PageView.Current for accessing the pageview instance in a frontend context.
[Obsolete("This will always return null or an exception... So using it will fail.")]
public static PageView GetPageview()

Returns

PageView

GetPageviewAsTemplate(int)

Creates a pageview, renders it and put the resulting markup into a template instance that can be used for further rendering. In the page that is being rendered, tags that will become available when this template is used for rendering, is accessible in the format {{tag.name}} Can be used to render a page and use the result for an email.
public static Template GetPageviewAsTemplate(int pageId)

Parameters

pageId int
The page to render and use as markup for the template

Returns

Template
Template instance with the markup of the rendered page where tag placeholders ({{tag.name}}) is converted into regular template tags

GetPageviewAsTemplate(int, Dictionary<string, object>)

Creates a pageview, renders it and put the resulting markup into a template instance that can be used for further rendering. In the page that is being rendered, tags that will become available when this template is used for rendering, is accessible in the format {{tag.name}} Can be used to render a page and use the result for an email.
public static Template GetPageviewAsTemplate(int pageId, Dictionary<string, object> contextValues)

Parameters

pageId int
The page to render and use as markup for the template
contextValues Dictionary<string, object>
Context parameters i.e. orderid

Returns

Template
Template instance with the markup of the rendered page where tag placeholders ({{tag.name}}) is converted into regular template tags

GetPageviewByPageID(int)

Retrieves an instance of the pageview of page specified by page ID. Use PageView.Current for accessing the pageview instance in a frontend context.
public static PageView GetPageviewByPageID(int pageId)

Parameters

pageId int
ID of a page.

Returns

PageView

Remarks

Returns a PageView object of that page specified by page ID

GetPageviewModel()

public PageViewModel GetPageviewModel()

Returns

PageViewModel

GetParagraphViewModels()

public IList<ParagraphViewModel> GetParagraphViewModels()

Returns

IList<ParagraphViewModel>

Load()

Loads the PageView object with data. Usually Dynamicweb handles this.
public void Load()

Remarks

Use Current(), or PageView.GetPageviewByPageID to get an instance.

Output()

Executes the pageview and parses all templates with content, modules and navigation.
public string Output()

Returns

string
The parsed HTML output of the pageview. Normally no need to call this as it is handled by Dynamicweb.

SetCurrentParagraph(Paragraph)

public void SetCurrentParagraph(Paragraph paragraph)

Parameters

paragraph Paragraph
To top