Setting page properties programmatically

Vote:
 
How can I set page properties programmatically? It's not a problem for build in properties like PageName... but properties defined in my PageType will just not last. For example when I create a page: ... PageData newPageData = Global.EPDataFactory.GetDefaultPageData(parentLink, pageTypeName); newPageData.PageName = "Testname" // no problem // but newPageData.Property["MyOwnStringProperty"] = "Teststring" // will not work // neither does newPageData["MyOwnStringProperty"] = new PropertyString("Teststring); // or newPageData.Property["MyOwnStringProperty"].value = new PropertyString("Teststring); // or any other combination I have tried. .... the property is actually saved but only temporarily What am I doing wrong?
#12314
Jul 05, 2005 11:30
Vote:
 
You haven't actually done anything wrong, it just takes a little more code to persist new page properties. Please have a look at this FAQ article for more info: http://www.episerver.com/templates/faq.aspx?id=4895
#14042
Jul 06, 2005 11:51
Vote:
 
That FAQ actually describes how to manipulate page types in code, normally you add your property "MyOwnStringProperty" in admin mode as a one-time configuration on the page type and then just assign a page property a value, look at the "How to: Create a Page Programatically" in the SDK for an example. Regarding assigning a property, here are your alternatives.. Alt1. newPageData["MyOwnStringProperty"] = "Teststring"; Alt 2 newPageData.Property["MyOwnStringProperty"].value = "Teststring";
#14043
Jul 07, 2005 8:55
Vote:
 
Thank you, I wasn't actually creating a page property just assigning. But the sample code showed me the way. I hadn't saved the page after setting the property ;) /René
#14044
Jul 07, 2005 9:09
* 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.