I've build a plugin-tool to admin mode, where one can enter the name of a property, it's expected current value and a new value.Press "Change" and all pages where the given property has the specified current value, it changes into the new value.
This works very well, if the property you want to change is of type string.
This tool was build to change the "Pages" property, so that you can enter a number value (the ID of a page) and another value (a new ID of a page) and press change, and all pages that point to a page with the old ID will instead point to a page with the new ID.However, the problem is that the "Pages" property needs a PageRefererence, not a string or an int, so I need to cast..
So my question is actually a two-part question:
First of..Is there a way to add a new value as a string or an object and let episerver to the casting for me, like: Page[propertyname] = newValue;
Is there a way to make a simple (but ugly) swith statement, and if so, how do I compare, since Page[propertyName].GetType() returns a type, and the PropertyDataType is an enum which returns a DataType..
CurrentPage.Property["propertyname"] gives you a PropertyData object. if you work on CurrentPage["propertyname"] you get the underline value of the property
PropertyData objects have the ParseToSelf function that have string as an input parameter...
Quess that will do the trick
Genius, works like a charm, thanks a million