Update DynamicContentControl property value in code behind



I am trying to change property values for a dynamic content control in the OnSavingPage event. I iterate through the DynamicContentFragemnts of a PropertyXhtml property and am able to access the properties I'm looking for. However changing them doesn't seem to have an effect. I've even rebuilt the full Xhtml property using the fragments I'm iterating through but the dynamiccontent control seems to render the same markup (using GetEditFormat function) after I've changed the properties.

I've also used the DynamicContentControl's property's SaveData method but this doesn't seem to work either. I suspect its something quite obvious I'm missing!

Has anyone tried this successfully before or have any ideas?


Sep 09, 2013 10:50
Sep 09, 2013 15:14

Thanks, unfortunately that post doesn't address my issue. I can change page properties in the OnPageSaving event without issue, its the properties belonging to dynamic content controls within page properties that I'm having issues with - and I suspect its due to how these dynamic content controls maintain their state.


foreach(var a in html.Fragments)


if(a is DynamicContentFragment)


var x = a as DynamicContentFragment; 

var y = x.GetEditFormat();

x.DynamicContent.Properties["PropertyName"] = "something else";

var z = x.GetEditFormat();

// The issue is that y & z are the same. 



Sep 09, 2013 16:49
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.