InnerProperty error

Vote:
 

Hi!

I am using the InnerProperty to set an property from an other page in code behind like this:

 

<EPiServer:Property ID="LinkProp" runat="server" DisplayMissingMessage="false"/>

 

PageData pd = EPiServer.DataFactory.Instance.GetPage(CurrentPage["PageNameProperty"] as PageReference);

PropertyData linkproperty = pd.Property["LinkName"];

if (linkproperty != null){
LinkProp.InnerProperty = linkproperty; 
}
 
This worked before I upgraded to CMS 6 R2 but now it does not seem to work correctly.
 
The stage thing is if I add an other copy of the same line, so the method look like this, it works (I found this after some debugging).
:
 
if (linkproperty != null){
LinkProp.InnerProperty = linkproperty;  
LinkProp.InnerProperty = linkproperty; 
}
 
 
 
What could cause this error?
 
Best regards
Andreas
 

 

 

#51922
Jun 28, 2011 17:11
Vote:
 

My guess is that you set InnerProperty too late so the Child Controls already are created.

Try to analyze the steps taken in each phase of the pages life cycle.

Try if a call to LinkProp.DataBind() will make the InnerProperty to work as expected. If yes, this is an indication of that the control called CreatedChildControls before InnerProperty was set and DataBind will clear all the child controls and recreate them. Note that a call to DataBind is not a a good solution.

#51923
Jun 29, 2011 1:17
Vote:
 

this did not solve my problem, but I changed it according to your "Best Coding Practices - EPiServer CMS", published in dec 2009... which I should have thought of earlier...

 

<div><EPiServer:Property PageLinkProperty="PageNameProperty" PropertyName="LinkName" runat="server" /></div>

 

So thanks anyway!

#51944
Jun 29, 2011 15:28
Vote:
 

Hi,

I'm having the same problem. I upgraded from 5R2 to 6R2 and started having this problem.

The following lines of code are run in CreateChildControls and were working fine before the upgrade:

            var pd = DataFactory.Instance.GetDefaultPageData(PageReference.StartPage, Settings.MetadataSetupDummyPageTypeId);

  emneProperty.InnerProperty = pd.Property["Emne"];

 

pd.Property["Emne"] is not null, but is a CustomProperty (when I check it in the debugger it is displayed as "EPiServer.Core.PropertyData {KL.KLDK.Web.Backend.CustomProperties.AutoCompleteSelector.AutoCompleteSelector}").

After the InnerProperty has been set with the code above, it's value is null. If you set it twice (run the same line of code twice) everything works fine.

 

This must be a bug somewhere...

My current workaround is running the code line twice, but some help with another way of doing this or a fix would be much appreciated.

Thanks

Daniel


#52983
Aug 24, 2011 9:56
Vote:
 

@Daniel: What value is null?

Using InnerProperty only affects internal values but does not trigger recreation of ChildControls.

Setting it twice sounds strange. When using the Reflector there is nothing that indicates that it should affect anything.

#52984
Aug 24, 2011 11:49
Vote:
 

Hi Fredrik,

emneProperty.InnerProperty == null  ==> true

 

That is until I set it the second time - then it equals pd.Property["Emne"].

 

Very strange problem. And I agree with you that there's no indication of this "multi setting" affecting it anyhow. I'm clueless...

BR
Daniel 

#52985
Aug 24, 2011 12:06
Vote:
 

Ah! I found it :)

It is a bug!

Setting InnerProperty first set _propertyData that is the backing field to InnerProperty.

Then it updated PropertyName to the value of InnerProperty.Name.

The setter for PropertyName clears _propertyData if the value is changed.

#52986
Aug 24, 2011 12:36
Vote:
 

That makes sense (well, it doesn't make sense that it does that, but now the reaction makes sense!). 

 

What's your suggestion concerning this? Just setting it twice seems to do the trick. Will you make sure it's fixed in upcoming releases?

 

Thank you for your swift and effective replies.

Daniel

#52987
Aug 24, 2011 12:43
Vote:
 
Bug #72634: Setting InnerProperty resets _pageData
#53005
Aug 24, 2011 21:12
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.