web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

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

Zhongchen Zhou Profile Picture Zhongchen Zhou 681

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%> 

This was originally posted here.

Comments

*This post is locked for comments