Innerproperty and html-editor

Vote:
 

After a postback i'm showing a html-editor on a EPiServer simplepage.

<EPiServer:Property id="ctlHtmlEditor" EditMode="true" runat="server" />

I'm adding the value to the property by using the innerproperty. I'm doing thing in the pageinit event.

PropertyXhtmlString oEditor = new PropertyXhtmlString();
oEditor.Name="_Editor";
oEditor.EditorToolOptions = EPiServer.Editor.EditorToolOption.All;
ctlHtmlEditor.InnerProperty = oEditor;

So far everything is fine. But efter postback/submit i'm unable to access the value of the property. I have tried ctlHtmlEditor.PropertyValue and ctlHtmlEditor.InnerProperty.Value.

#25706
Nov 03, 2008 7:38
Vote:
 

I quess this is on EPiServer 4?

Had the same problem a while ago, dont remember what I did but it was either

bool test = true;
_prop.ParseValidation(null,new ServerValidateEventArgs(_prop.ToString(), test));

or

finding the inner value textbox with FindControl("_Editor")
and retrive the content from Request object

Hope it helps

#25720
Nov 03, 2008 12:27
Vote:
 

It's on EPiServer 5.1 and i'm converting the code from 4.6. On 4.6 I used CurrentPage.property.add insted of using the innerproperty but it's not possible anymore. The property.add i "read only" in EPiServer 5.

I got the code working using Request object but it feels wrong.

#25722
Nov 03, 2008 12:48
Vote:
 

Think you have to Find the   IPropertyControl control inside the ctlHtmlEditor

try

IPropertyControl ctr=ctlHtmlEditor.controls[0] as IPropertyControl 

ctr.ApplyChanges();

now I quess the value is set... (sorry about links, using reflector)

#25730
Nov 03, 2008 15:13
Vote:
 

Hi

I'm assuming your code is on a page that in some form inherits from PageBase. What you need to do is to call the method PrepareForSave(), that you can find on PageBase, before you check the value.

PrepareForSave() will call ApplyChanges() on all controls that are of the type IPropertyControl which will set the value, as Anders said.

Also you need to make sure that your PropertyXhtmlString is writeable.

I think Linus Ekström wrote a good forum reply regarding this, too lazy to find it now though ;)

Regards

Per Gunsarfs
EPiServer CMS development team

#25736
Nov 03, 2008 16:40
Vote:
 

I think the CurrentPage is ReadOnly in the scheme is Thomas describing. So that function Per is pointing to would not work,  but the function that PreperForSave is using SetValuesForPropertyControls(Control control) looks like it does the trick.

Havent looked in PageBase in a long time I see Embarassed
Many nice function here

 

Edit:typos

#25739
Edited, Nov 03, 2008 20:09
Vote:
 

Hi,

the other forum post that Per refers to is this,

http://world.episerver.com/Forum/Pages/Thread.aspx?id=19369&epslanguage=en

but I'll think its time for an article about this...

#25740
Nov 03, 2008 20:55
Vote:
 

Hi,

Thanks for all the response Smile.

Anders code did the trick.

IPropertyControl ctr = ctlHtmlEditor.Controls[0] as IPropertyControl;
ctr.ApplyChanges();

I then used ctlHtmlEditor.PropertyValue.ToString() to access the value. I first tried the PrepareForSave but not luck there. The other thread hade no solution for this what I could find.

#25741
Nov 03, 2008 21:41
Vote:
 

That was good news

Just for the record, I would have used the SetValuesForPropertyControls(ctlHtmlEditor) insted of ctlHtmlEditor.Controls[0]  Laughing

#25742
Nov 03, 2008 22:07
* 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.