I was playing with the Umbraco API to figure out what would be the best scenario for me to implement my custom datatype. When to create the child controls, when to load the data and so on. In my test implementation I just wanted to explore the lifecycle of a datatype instance. I implemented four classes for the purpose, which were:
CustomDataType: inherits form BaseDataType, implements IDataType
CustomData: inherits from DefaultData
CustomDataEditor: inherits from UserControl, implements IDataEditor
CustomDataPrevalueEditor: inherits from UserControl, implements IDataPrevalue (this class does not play too much now)
Every classes have a unique name, which is created automatically, and I traced all the method calls and object constructions which were initiated by the Umbraco runtime. These are the results for four different scenarios:
creating the datatype by adding a new content
loading the datatype by loading the content properties
postback form the datatype ui by the one and only ui element which I used, a Button
saving the datatype by saving the content properties
Here are the results, which I cannot understand clearly:
The numbers after the type name are instance indexes. According to the results, for a simple postback, LoadValueFromDatabase method is called two times. During save, it is called three times. At least two instances are created from every object for every scenario.
I know that ASP.Net is a kind of complicated technology, with weird behavior. Now what I don't know, how I can distinguish the calls from each other, to avoid loading my data multiple times? (Don't say I should count the calls.) I am a bit confused now.
I am sure, there is a rational explanation. Any comment is appreciated. I can upload or send the full commented source code, if needed.
Creating a custom datatype by implementing IData
Hi,
I was playing with the Umbraco API to figure out what would be the best scenario for me to implement my custom datatype. When to create the child controls, when to load the data and so on. In my test implementation I just wanted to explore the lifecycle of a datatype instance. I implemented four classes for the purpose, which were:
CustomDataType: inherits form BaseDataType, implements IDataType
CustomData: inherits from DefaultData
CustomDataEditor: inherits from UserControl, implements IDataEditor
CustomDataPrevalueEditor: inherits from UserControl, implements IDataPrevalue (this class does not play too much now)
Every classes have a unique name, which is created automatically, and I traced all the method calls and object constructions which were initiated by the Umbraco runtime. These are the results for four different scenarios:
Daniel -
Just came across your post...have a look at the post Tim put together covering this topic for some ideas
http://www.nibble.be/?p=50
-Paul
is working on a reply...