Home > Dynamics Ax > Hide/Show the Dynamics Ax EP web parts

Hide/Show the Dynamics Ax EP web parts


In some scenarios, in a single web page we need to Hide/Show the certain web parts based on the user profile.

By using the following code snippets we can Hide the web parts of the page.

 

This example is for Hiding

1)      AxToolbarWebPart

2)      AxUserControlWebPart

 

Hidding the Toolbar

 

private void hideWebMenuToolBar()

    {

        WebPartManager webPartManager = WebPartManager.GetCurrentWebPartManager(this.Page) as WebPartManager;

        AxToolbarWebPart toolBarWebPart;

        

        for (int i = 0; i < webPartManager.WebParts.Count; i++)

        {

             toolBarWebPart = webPartManager.WebParts[i] as AxToolbarWebPart;           

 

            if (toolBarWebPart != null && toolBarWebPart.WebMenuName == "TmCustomers")

            {

                toolBarWebPart.Hidden = true;

                break;

            }    

 

        }

    }

 

Hidding the User control webpart

 

    private void hideWebPart()

    {

        WebPartManager webPartManager = WebPartManager.GetCurrentWebPartManager(this.Page) as WebPartManager;

        AxUserControlWebPart webPart;

 

        for (int i = 0; i < webPartManager.WebParts.Count; i++)

        {

            webPart = webPartManager.WebParts[i] as AxUserControlWebPart;

 

            if (webPart != null && webPart.ManagedContentItem == "TmMattersGrid")

            {

                webPart.Hidden = true;

                break;

            }

        }

    }

Smile

Advertisements
Categories: Dynamics Ax
  1. Santosh.
    October 7, 2009 at 5:01 am

    Good one 🙂

  2. Santosh Kumar
    October 7, 2009 at 5:29 am

    Thanks dear

  3. Hani
    November 19, 2009 at 7:27 am

    Thanks a lot Santosh, I was looking for this code it helps me a lot. Very Good brother 🙂

  4. Santosh Kumar
    November 19, 2009 at 10:12 am

    u r welcome Hani… 🙂

  1. No trackbacks yet.

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

%d bloggers like this: