November Happy Hour will be moved to Thursday December 5th.

Find Current PageWorkId / WorkId

Vote:
 

Hi,
I am trying to find current PageWorkId / WorkId. I need this to populate custom data (control) on the page. The data is stored separately from EpiServer database.
I have tried following code but None of this is returning me Current WorkId.
1)
var currentPage = HttpContext.Current.CurrentHandler as PageBase;            
if (currentPage != null)            
{                
// Get the Time table details                
_clubId = currentPage.CurrentPage.PageLink.ID;                
_versionId = currentPage.CurrentPage.PageLink.WorkID; //CurrentPage.WorkPageID;            
}
2)
PageData page = DataFactory.Instance.GetDefaultPageData(CurrentPage.PageLink, CurrentPage.PageTypeID);
// page's current PageLink have WorkId = 0
3)
4)
 
 The following code works, but only for latest version. 
Issue:
If admin user compare two pages he will see same data on page as both will render the data for latest version.
I want the current selected version Id for the current page.
If anyone have better solution to find the WorkId, is highly appericiated.
Thanks
Sanjay

Hi,
I am trying to find current PageWorkId / WorkId.

I need this to populate custom data (control) on the page. The data is stored separately from EpiServer database.


I have tried following code but None of this is returning me Current WorkId.
1)
var currentPage = HttpContext.Current.CurrentHandler as PageBase;            

  if (currentPage != null)            

  {                

  _pageId = currentPage.CurrentPage.PageLink.ID;                

  _versionId = currentPage.CurrentPage.PageLink.WorkID; //CurrentPage.WorkPageID; 

  }

2)
PageData page = DataFactory.Instance.GetDefaultPageData(CurrentPage.PageLink, CurrentPage.PageTypeID); // page's current PageLink have WorkId = 0
3)
PageReference pageRef1 = CurrentPage.PageLink;
4)

PageReference pageRef2 = CurrentPageLink;

  
 The following code works, but only for latest version. 

PageReference pageRef = MyDataHelper.GetCurrentPublishedVersion(CurrentPage); // **

if (pageRef != null)

{

_pageId = pageRef.ID;

_versionId = pageRef.WorkID;

}

** - GetCurrentPublishedVersion is a custom method which iterate through all versions and return published version.

Issue:
 If admin user compare two pages he will see same data on page as both will render the data for latest version.
I want the current selected version Id for the current page.
If anyone have better solution to find the WorkId, is highly appericiated.
Thanks
Sanjay
#38984
Apr 27, 2010 14:36
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.