03-18-06 08:18 AM
Hi James,
are you in update when clicking this button?
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"James Coleman" <JamesColeman@discussions.microsoft.com> wrote in message
news:F4E524F7-81D1-4A79-BAF4-25EBE6BF7EFC@microsoft.com...
>I am trying to create a template that basically allows a user to edit a
>class
> in which I then serialize into xml and then store into the
> xmlhtmlplaceholder
> of a cms template. When I try to do a posting.submit, I get an error
> thrown
> saying that the object is readonly (even though posting.cansubmit is
> true).
> Any help would be appreciated.
>
> using System;
> using System.Data;
> using System.Configuration;
> using System.Collections;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
> using Microsoft.ContentManagement.Publishing;
> using Microsoft.ContentManagement.WebControls;
> using Allsteel.Library;
>
> public partial class Templates_Product : System.Web.UI.Page
> {
> private Product product;
> private Posting posting;
> private Boolean authorMode;
> protected void Page_Load(object sender, EventArgs e)
> {
> this.Master.Page.Title =
> CmsHttpContext.Current.Posting.DisplayName;
> posting = CmsHttpContext.Current.Posting;
>
> WebAuthorContextMode mode = WebAuthorContext.Current.Mode;
> if (mode == WebAuthorContextMode.AuthoringNew || mode ==
> WebAuthorContextMode.AuthoringPreview || mode ==
> WebAuthorContextMode.AuthoringReedit){
> authorMode = true;
> }
> pnlEdit.Visible = authorMode;
> pnlPresent.Visible = !authorMode;
> product = new Product();
>
> if (Page.IsPostBack)
> {
> if (Session["Product"] != null)
> {
> product = (Product)Session["Product"];
> }
> }
> else
> {
> string xml =
> posting.Placeholders["Product"].Datasource.RawContent;
> if (xml.Length > 0)
> {
> product = ProductDAO.Deserialize(xml);
> SynchPresentation();
> }
> }
> }
> protected void SynchPresentation()
> {
> if (authorMode)
> {
> tbName.Text = product.Name;
> reOverview.Html = product.OverviewBody;
> }
> else
> {
> lblName.Text = product.Name;
> litOverview.Text = product.OverviewBody;
> }
> }
> protected void SynchClass()
> {
> product.Name = tbName.Text;
> product.OverviewBody = reOverview.Xhtml;
> }
> protected void btnSave_Click(object sender, EventArgs e)
> {
> SynchClass();
> Session["Product"] = product;
> String xml = ProductDAO.Serialize(product);
> posting.Placeholders["Product"].Datasource.RawContent = xml;
> if (posting.CanSubmit)
> {
> posting.Submit();
> }
> }
> }
>
>
> --
> James Coleman
> Technical Director
> AGENCY.COM [Chicago]
> jcoleman@agency.com
>
>
[ Post a follow-up to this message ]
|