Dynamics CRM 2011 Portal Development – PortalContext/CurrentContact/Website Expression

Dynamics CRM 2011 Portal Development

PortalContext Expression

Syntax:

<%$ Context: Property=property, Attribute=attribute, Eval=eval, Format=format, Default=default, Portal=portal%>
<%$ Context: property, attribute, eval, format, default, portal%>

PortalContext Expression takes a format of comma separated name value pairs, any pair is optional and the name of the pair is optional as well. If name is omitted, then the sequence is significant.

The first name value pair (Property) is the property name of IPortalContext instance. IPortalContext interface defined six properties:

public interface IPortalContext
{
    Microsoft.Xrm.Sdk.Entity Entity { get; }
    string Path { get; }
    OrganizationServiceContext ServiceContext { get; }
    System.Net.HttpStatusCode StatusCode { get; }
    Microsoft.Xrm.Sdk.Entity User { get; }
    Microsoft.Xrm.Sdk.Entity Website { get; }
}

If “Current” is specified as the value, the current PortalContext instance will be the result of the expression. If any other valide IPortalContext property name is specified, that property value is retrieved for the rest of the expression evaluation. If that property is null and the expression should be evaluated to a string value then the default value specified in 5th name value pair will be the result of the expression. Otherwise null will be returned from expression evaluation.

The second name value pair (Attribute) is only effective if the property of the previously retrieve property of IPortalContext is an Entity. If property of IPortalContext is an Entity, will be used for the rest of the evaluation, otherwise IPortalContext.Property is used for the rest of the evaluation. The value will be either

System.Web.UI.DataBinder.Eval(IPortalContext.Property[Attribute], eval, format)

or

System.Web.UI.DataBinder.Eval(IPortalContext.Property, eval, format)

Examples 1:

<asp:Literal runat="server" Text="<%$ Context: Property=Path%>" />

will produce the following output

~/Pages/Home.aspx?pageid=978e66cc-c8c6-4e5c-9ce0-d6ff153e9722

Examples 2:

<asp:Literal runat="server" Text="<%$ Context: Property=Entity, Attribute=Current, Eval=LogicalName%>" />

will produce the following output

adx_webpage

Examples 3:

<asp:Literal runat="server" Text="<%$ Context: Property=Entity, Attribute=adx_name%>" />

will produce the following output

Home

Examples 4:

<asp:Literal runat="server" Text="<%$ Context: Property=Website, Attribute=Current, Eval=LogicalName%>" />

will produce the following output

adx_website

Examples 5:

 <asp:Literal runat="server" Text="<%$ Context: Property=Website, Attribute=adx_name%>" /> 

will produce the following output

Cusomer Portal

CurrentContact Expression

CurrentContact Expression is a shortcut of PortalContext Expression with Property set to User

<%$ Context: Property=User, Attribute=attribute, Eval=eval, Format=format, Default=default, Portal=portal%>
<%$ Context: User, attribute, eval, format, default, portal%> 

Website Expression

Website Expression is a shortcut of PortalContext Expression with Property set to Website

<%$ Context: Property=Website, Attribute=attribute, Eval=eval, Format=format, Default=default, Portal=portal%>
<%$ Context: Website, attribute, eval, format, default, portal%> 
Advertisements

4 comments on “Dynamics CRM 2011 Portal Development – PortalContext/CurrentContact/Website Expression

  1. Pingback: Dynamics CRM 2011 Portal Development – Snippet/SiteSetting Expression | Zhongchen Zhou's Blog

  2. Pingback: Dynamics CRM 2011 Portal Development – CrmSiteMap Expression | Zhongchen Zhou's Blog

  3. Pingback: Dynamics CRM 2011 Portal Development – TimeZone Expression | Zhongchen Zhou's Blog

  4. Pingback: Dynamics CRM 2011 Portal Development | Zhongchen Zhou's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s