tags:

views:

65

answers:

3

Hi,

What is the difference between accessing a property through page["propertyName"] and page.Property["propertyName"] in EPiServer?

Thanx!

A: 

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

Johan Kronberg
+1  A: 

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

Bjorn Isaksen
Are you sure that page["PropName"] == page.Property["PropName"]= The first returns an object, the latter a PropertyData object. When running trough a debugger it equalse to false.
Clean
I never said page["PropName"] == page.Property["PropName"], quite the opposite) (watch the last .value :)
Bjorn Isaksen
A: 

As Bjorn said:

CurrentPage["PropertyName"] is the same as CurrentPage.Property["PropertyName"].Value.

Ted Nyberg