SaaS CMS has officially launched! Learn more now.

CurrentPage["Property"] only works in view mode

Vote:
 

The code below only gives the expected result while viewing the page but not in edit mode. Any idea why?

    int i;

    int.TryParse(CurrentPage.Property["PageLink"], out i);

 

#82586
Mar 14, 2014 20:39
Vote:
 

Hi,


That's because PageLink is not always an int. In edit mode it also has a work id, so you need to treat PageLink as a string. If you just want the just the id, you can do CurrentPage.PageLink.ID.

#82590
Mar 16, 2014 6:15
Vote:
 

Or:

var pageReference = CurrentPage.Property["PageLink"] as PageReference;

var id = pageReference.ID;

    

#82591
Edited, Mar 16, 2014 6:17
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.