November Happy Hour will be moved to Thursday December 5th.

Update DynamicContentControl property value in code behind

Vote:
 

Hi,

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?

Thanks

#74825
Sep 09, 2013 10:50
Vote:
 
#74833
Sep 09, 2013 15:14
Vote:
 

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.

eg.

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. 

}

}

#74838
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.