»»» technology + aesthetics «««

DAX 2009 Enterprise Portal Development : Using the Ax Session

Accessing the Session object

When adding code to User Controls for Enterprise Portal, many of the methods that you will use in the Enterprise Portal framework require access to the session object, for holding temporary values of the session, passing values between pages in Enterprise Portal.

Steps to access the session object

·         The Session object can be accessed through the AxWebPart hosting the AxUserControl.

·         The following namespaces have to be included in the User control to access the WebPart hosting the control and the Session object used by it.

using Microsoft.Dynamics.Framework.Portal.UI.WebControls.WebParts;

using Microsoft.Dynamics.Framework.BusinessConnector.Session;

·         The following accessor method can be added to the code to fetch the active Session object

AxBaseWebPart webPart;   

    protected AxBaseWebPart WebPart

    {

        get

        {

            if (webPart == null)

                webPart = AxBaseWebPart.GetWebpart(this);

 

            return webPart;

        }

    }

protected ISession AxSession

    {

        get

        {

            AxBaseWebPart webpart = this.WebPart;

            return webpart == null ? null : webpart.Session;

        }

    }

·         The getter method can be used as described in the following examples

1.    AxSession.AxaptaAdapter

2.    e.DataSetRunArgs.parmEnumType = EnumMetadata.EnumNum(this.AxSession, "name");

3.    AxSession.GetItemFromCache("name");

4.    AxSession.SetItemInCache("name", AxGridView1.SelectedDataKey.Value.ToString());

 

 References

·      http://msdn.microsoft.com/en-us/library/cc581944.aspx

 


Feedback

No comments posted yet.