posting.submit() causes error because it is read only
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > posting.submit() causes error because it is read only




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    posting.submit() causes error because it is read only  
James Coleman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-18-06 08:18 AM

I am trying to create a template that basically allows a user to edit a clas
s
in which I then serialize into xml and then store into the xmlhtmlplaceholde
r
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 ]



    Re: posting.submit() causes error because it is read only  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Re: posting.submit() causes error because it is read only  
James Coleman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-19-06 04:59 PM

Thanks Stefan for the response.  Sorry about the mulitiple postings, when I
was submitting I was getting an error and I didn't realize my post was makin
g
its way in.

I guess I don't know what object and property you want me to check to see if
I am in "update".

The WebAuthorContext.Current.Mode at the time of the posting.submit() is
WebAuthorContextMode.AuthoringReedit.

I will continue to poke around and try and figure it out myself because I am
assuming you take the weekend off.

~James

--
James Coleman
Technical Director
AGENCY.COM [Chicago]


"Stefan [MSFT]" wrote:

> 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[/url...nyurl.com/8ugwj
> ----------------------
>
>
> "James Coleman" <JamesColeman@discussions.microsoft.com> wrote in message
> news:F4E524F7-81D1-4A79-BAF4-25EBE6BF7EFC@microsoft.com... 
>
>
>





[ Post a follow-up to this message ]



    Re: posting.submit() causes error because it is read only  
James Coleman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-19-06 04:59 PM

Okay, it looks like the CmsHttpContext.Current.Mode is equal to Unpublished
when the page loads from by own save button control.

When I click the 'Save' from the defaultconsole.ascx then the
CmsHttpContext.Current.Mode is in Update mode.  So I either need to set the
CmsHttpContext.Current.Mode = to Update (which is readonly - so I don't know
how to do that) or I need to find out how I can get my own code to run when
the 'Save' within the defaultconsole.ascx is clicked.

Any ideas/help would be greatly appreciated.
--
James Coleman
Technical Director
AGENCY.COM [Chicago]


"Stefan [MSFT]" wrote:

> 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[/url...nyurl.com/8ugwj
> ----------------------
>
>
> "James Coleman" <JamesColeman@discussions.microsoft.com> wrote in message
> news:F4E524F7-81D1-4A79-BAF4-25EBE6BF7EFC@microsoft.com... 
>
>
>





[ Post a follow-up to this message ]



    Re: posting.submit() causes error because it is read only  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-06 01:03 PM

Hi James,

the correct way to do this is to implement a workflow event.
Here e.Context will be in Update mode.

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:6A03160E-A221-4489-8972-57DF301E2608@microsoft.com...[vbcol=seagreen]
> Okay, it looks like the CmsHttpContext.Current.Mode is equal to
> Unpublished
> when the page loads from by own save button control.
>
> When I click the 'Save' from the defaultconsole.ascx then the
> CmsHttpContext.Current.Mode is in Update mode.  So I either need to set
> the
> CmsHttpContext.Current.Mode = to Update (which is readonly - so I don't
> know
> how to do that) or I need to find out how I can get my own code to run
> when
> the 'Save' within the defaultconsole.ascx is clicked.
>
> Any ideas/help would be greatly appreciated.
> --
> James Coleman
> Technical Director
> AGENCY.COM [Chicago]
>
>
> "Stefan [MSFT]" wrote:
> 







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:13 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register