次の方法で共有


Whats the quickest way to get a reference to the current Portal Area via a Web Part?

Useful little code snippet that answers a common question. 

This is the most efficient way I know of to retrieve a reference to the Portal Area a web part is instantiated on.

Let me know if you have a better way! (Wouldn't it be nice if it were just a single line?)


SPWeb ThisWeb = SPControl.GetContextWeb(Context);

PortalContext ThisPortalContext = PortalApplication.GetContext(Context);

Area thisArea = AreaManager.GetArea(ThisPortalContext, ThisWeb.ID);

AreaTitle = thisArea.Title;

Comments

  • Anonymous
    April 14, 2004
    The comment has been removed
  • Anonymous
    April 14, 2004
    oops, one more semicolon there than there oughta be
  • Anonymous
    April 15, 2004
    The comment has been removed