Property Exists vs Property Not Set

Vote:
 

I need a way to tell whether a page does not have a particular property defined versus having the property defined but no value set.  How can I do this?

pseudo code for what I want to accomplish:

if(CurrentPage contains a property called "theProperty")
    if(CurrentPage["theProperty"] != null)
        do something...

I only want to apply the logic in the second "if" statement if the page has a property called "theProperty" defined.

Thanks!

#63421
Nov 19, 2012 18:50
Vote:
 

If a property is not set it will not be saved in the database. But I guess you could load the actual pagetype definitions to check if your property exists. 

 

Check out the PageType class. 

 

#63430
Nov 19, 2012 19:22
Vote:
 

There is a function in the property class:

CurrentPage.Property.ExistsLocally("MyProp")

http://sdk.episerver.com/library/cms5/html/M_EPiServer_Core_PropertyDataCollection_ExistsLocally.htm 

#63431
Nov 19, 2012 20:41
Vote:
 

Cr*p I've totally missed that one possibility.

#63432
Nov 19, 2012 20:48
Vote:
 

That might do it.  Testing now.

#63433
Nov 19, 2012 21:03
Vote:
 

Done and done.

Thanks!

#63434
Nov 19, 2012 21:11
Vote:
 

Your'e welcome :)

 

#63435
Nov 19, 2012 21:20
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.