Microsoft Content Management Server - Placing content into a placeholder on an existing posting programmatically

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > November 2004 > Placing content into a placeholder on an existing posting programmatically





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Placing content into a placeholder on an existing posting programmatically
DaveB

2004-11-26, 2:46 am

I know you can put content in to placeholders when a posting is
created. But is it possible to change the content in the placeholders
once the posting is already created, without navigating to the posting
in update mode.
Jakub Skopal

2004-11-26, 2:46 am

Hello Dave,

this cannot be done via CmsHttpContext (unless you redirect the user
into update mode), which you probably already figured out.
nevertheless, this still can be done (even from a web page) via
connecting to the same CMS database via CmsApplicationContext
see
http://msdn.microsoft.com/library/d...tclasstopic.asp

Jakub

DaveB wrote:
> I know you can put content in to placeholders when a posting is
> created. But is it possible to change the content in the placeholders
> once the posting is already created, without navigating to the posting
> in update mode.

Stefan [MSFT]

2004-11-26, 5:49 pm

Hi Dave,

you need to ensure that the context accessing the posting is in update mode.
But it is not necessary to navigate to this posting.
The posting can also be accessed from any other posting if you ensure that
the CmsHttpContext is in update mode.
If this is not an option, choose CmsApplicationContext and authenticate in
update mode using this context.

Cheers,
Stefan.


"DaveB" <david_brownlow@yahoo.co.uk> wrote in message
news:a55af233.0411252112.112cb4c7@posting.google.com...
> I know you can put content in to placeholders when a posting is
> created. But is it possible to change the content in the placeholders
> once the posting is already created, without navigating to the posting
> in update mode.



DaveB

2004-11-28, 5:48 pm

Thankyou for you reply.
I am trying to use CmsApplicationContext but when I use the following
code using a user with admin rights:-

myCMSContext = New CmsApplicationContext()
myCMSContext.AuthenticateAsUser(<Username>,<Password>,PublishingMode.Update)
myPosting = CmsHttpContext.Current.Searches.GetByGuid (<Long number> )
myhtmlPlaceholder = myPosting.Placeholders(<placeholder name> )

myhtmlPlaceholder.Html = newHtml

this line fails with
System.Runtime.InteropServices.COMException: Invalid mode for update.
The requested action modifies the state of an object and can only be
performed when the session is in the 'Update' mode.
but CMSContext.Mode is returning a value of 'Update'

If I can not change the content of a placeholder like this, how else
can I do it.
Any help would be great.




"Stefan [MSFT]" <stefang@online.microsoft.com> wrote in message news:<eR86bf60EHA.2292@TK2MSFTNGP15.phx.gbl>...[vbcol=seagreen]
> Hi Dave,
>
> you need to ensure that the context accessing the posting is in update mode.
> But it is not necessary to navigate to this posting.
> The posting can also be accessed from any other posting if you ensure that
> the CmsHttpContext is in update mode.
> If this is not an option, choose CmsApplicationContext and authenticate in
> update mode using this context.
>
> Cheers,
> Stefan.
>
>
> "DaveB" <david_brownlow@yahoo.co.uk> wrote in message
> news:a55af233.0411252112.112cb4c7@posting.google.com...
Stefan [MSFT]

2004-11-29, 7:50 am

Hi Dave,

you are modifying an object that has been retrieved using the CmsHttpContext
and not using the CmsApplicationContext.

Change the code as follows:

myCMSContext = New CmsApplicationContext()

myCMSContext.AuthenticateAsUser(<Username>,<Password>,PublishingMode.Update)
myPosting = myCMSContext.Searches.GetByGuid (<Long number> )
myhtmlPlaceholder = myPosting.Placeholders(<placeholder name> )

myhtmlPlaceholder.Html = newHtml

Cheers,
Stefan.

"DaveB" <david_brownlow@yahoo.co.uk> wrote in message
news:a55af233.0411281531.1b451c71@posting.google.com...
> Thankyou for you reply.
> I am trying to use CmsApplicationContext but when I use the following
> code using a user with admin rights:-
>
> myCMSContext = New CmsApplicationContext()
>

myCMSContext.AuthenticateAsUser(<Username>,<Password>,PublishingMode.Update)
> myPosting = CmsHttpContext.Current.Searches.GetByGuid (<Long number> )
> myhtmlPlaceholder = myPosting.Placeholders(<placeholder name> )
>
> myhtmlPlaceholder.Html = newHtml
>
> this line fails with
> System.Runtime.InteropServices.COMException: Invalid mode for update.
> The requested action modifies the state of an object and can only be
> performed when the session is in the 'Update' mode.
> but CMSContext.Mode is returning a value of 'Update'
>
> If I can not change the content of a placeholder like this, how else
> can I do it.
> Any help would be great.
>
>
>
>
> "Stefan [MSFT]" <stefang@online.microsoft.com> wrote in message

news:<eR86bf60EHA.2292@TK2MSFTNGP15.phx.gbl>...[vbcol=seagreen]
mode.[vbcol=seagreen]
that[vbcol=seagreen]
in[vbcol=seagreen]


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com