Hi,
What is the difference between accessing a property through page["propertyName"] and page.Property["propertyName"] in EPiServer?
Thanx!
Hi,
What is the difference between accessing a property through page["propertyName"] and page.Property["propertyName"] in EPiServer?
Thanx!
Don't know exactly. But...
I always use page["PropName"] which I know works with "Fetch data from" and "Dynamic properties" and when you have a writable page it also works for setting a value.
Judging by code I've seen from multiple partners and at EPiServer courses it's the most common way too.
You can look at the implementation here and find out exactly: http://sdk.episerver.com/library/cms5/html/T_EPiServer_Core_PageData.htm
page["PropName"] uses the indexer of the PageData class to return the Value of the PropertyData object.
page.Property["PropName"] will return the whole PropertyData object (for example a PropertyLongString)
so page["PropName"] equals page.Property["PropName"].Value
As Bjorn said:
CurrentPage["PropertyName"] is the same as CurrentPage.Property["PropertyName"].Value.