Hi!
Have you debugged the code to see if the data has been populated for the text boxes and that the code actually does what you want it to do? Are versions created when you look in the regular EPiServer edit interface and does the changes get reflected when loading versions here?
I solve the problem!
I got my brain shutted down when start writing the code-behind... I forgot "if (!Page.IsPostBack) { ... }" block in the Page_OnLoad() event handler - shame on me...
The next problem - is to invoke the built-in editor. Can someone advise me about the typical way of invoking the <EPiServer.Property>'s editor? Setting 'EditMode' to 'true' don't do anything useful - I get the browser's error where I can see 'EPi.Dialog is null or not an object'.
So, I have an aspx-form, an EPiServer.Property on it and I'd like to 'force run' the build-in editor.
Hi!
Check out the following thread, http://www.episerverworld.com/Forum/Pages/Thread.aspx?id=19369&epslanguage=en.
Linus wrote a reply about how that can be done in EPiServer CMS 5.
I feel myself completely stupid...
I got editor running at last (thanks to the article written by Linus!) but now I cannot get changes back to be written to the DB :)
I got the <EPiServer:Property>-component - how can I simply get the edited value in the same way as it may be done with ordinary <asp:TextBox> by accessing its "Text" property (myWritablePage.Property["MainBody"].Value = tbMainBody.Text;)?
Let's suppose I have the property named "propMainBody".
Thank you in advance.
Hi again!
Unfortunately we do not have a property for the value of the inner property of the property web control but this is something that we will have in mind for future releases.
If you just want to update the current page properties you can call the method SavePage() that exists on EPiServer.PageBase. This methods requires a writable version of the current page and this has to be set up early in the page life cycle. We have example code for this for the start page of the workroom page in the demo templates where we solve this by override the CurrentPage property of the page and set it to a writable clone if required at the first request in the page.
Regards
Linus Ekström
EPiServer Development Team
Greetings, Linus!
Let me explain what I'm trying to do so you can recommend me something.
I have a static aspx-form (created as EPiServer template) and I'm referencing it with direct call, not using any kind of content pages made "over" this template. I think this shouldn't be required for the simple service form. Inside Page_Load event handler I'm checking for the "pageid" query string parameter and if it isn't null - I'm loading the content page with this provided ID, using something like this:
PageData mypage = DataFactory.Instance.GetPage(new PageReference(intPageID));
Next, I'm filling usual <asp:TextBox>-es with properties of this "mypage" instance. And, when stayng on this path - I got everything I need except for the lack of this good internal RichText Editor. The final strings from the event handler which is hooked to the <asp:Button> to confirm the edit process, looks like this:
PageReference prEditedPage = DataFactory.Instance.Save(writablepage, SaveAction.Publish);
Response.Redirect(DataFactory.Instance.GetPage(prEditedPage).LinkURL);
As you understand from my eralier postings - I'd like to use something more intelligent than "dumb" TextBox for editing my content. So I've simply placed an <EPiServer:Property> on my page, set its PropertyName and PageLink values accroding to the original data which I'd like to edit:
propMainBody.PropertyName = "MainBody"; propMainBody.PageLink = mypage.PageLink; propMainBody.EditMode = true; propMainBody.DataBind();
And it works! I've got the editor, which allows me to edit everything. But I still don't understand how may I save changes. Because I'm working with "static" page - I think updating properties of the current page won't do anything usefull (I may be wrong of course, I don't know much about EPiServer developping yet).
PS: I'm sorry but we here in Moscow failed to get "public template" (and "demo template" too, of course) properly installed with EPiServer SDK... So we can only study code-behinds...
PPS: Sorry for my poor (sometimes) English...
Best regards,
Andrey
If you just want to update the current page properties you can call the method SavePage() that exists on EPiServer.PageBase. This methods requires a writable version of the current page and this has to be set up early in the page life cycle. We have example code for this for the start page of the workroom page in the demo templates where we solve this by override the CurrentPage property of the page and set it to a writable clone if required at the first request in the page.
I can't find the example code you're speaking about. Could you tell me a name of the file in which this sample may be located?
And I still don't have any success in my task...
Hi!
Here is some code that you can use to extract the value of your editor when using the property control. (Se the id of your property to "MainBodyProperty" in the code front)
PropertyData writableProperty = MainBodyProperty.InnerProperty.CreateWritableClone();
PropertyDataControl innerPropertyControl = MainBodyProperty.Controls[0] as PropertyDataControl;
innerPropertyControl.PropertyData = writableProperty;
innerPropertyControl.ApplyEditChanges();
object myValue = writableProperty.Value;
Regards
Linus Ekström
Hi Linus,
Just tried your code and it worked perfectly!
I wanted to let my users edit the MainBody property on a page. After authenticating the user and checking his rights I opened my page with the MainBody with EditMode = true;
codebehind:
PageData writeableClone = CurrentPage.CreateWritableClone();
PropertyData writeableProperty = epMainBody.InnerProperty.CreateWritableClone();
PropertyDataControl innerPropertyControl = episerverMainBody.Controls[0] as PropertyDataControl;
if (innerPropertyControl != null)
{
innerPropertyControl.PropertyData = writeableProperty;
innerPropertyControl.ApplyEditChanges();
object myValue = writeableProperty.Value;
writeableClone.Property["MainBody"].Value = myValue.ToString();
DataFactory.Instance.Save(writeableClone, SaveAction.Publish);
Response.Redirect(writeableClone.LinkURL);
}
Hello!
I need some advice regarding the process of creation of the custom "Edit-mode" page. I'd like to make my own content creating/editing visual interface for, let's say, 'News' section of some site. I have an aspx-form with a set of textBoxes and som ecode-behind:
From Page_Onload:
And this is from the <asp:Button>'s 'OnClick' event handler:
The idea were taken from this good example: http://labs.episerver.com/Blogs/Ted-Nyberg/Dates/112276/3/Modify-and-publish-a-page-programmatically/
But... In my case the only one result I get - is the similar content for several varsions of the same page. Even if I change the content in text boxes - I keep getting the original one (i.e. the unchanged original content). What I'm doing wrong?