SaaS CMS has officially launched! Learn more now.

CurrentPage["Property"] only works in view mode


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);


Mar 14, 2014 20:39


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.

Mar 16, 2014 6:15


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

var id = pageReference.ID;


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.