SavePlaceholderContent
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 > SavePlaceholderContent




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

    SavePlaceholderContent  
Kimberley


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


 
08-27-04 11:08 PM

Hi,

I've created a checkbox placeholder and in the Protected Overrides Sub
SavePlaceholderContent method I want to set Custom Properties against
the posting based on the checkbox selections from the user.  It works
without any problems when I edit old content however when I create new
content I get an Invalid Cast Specified Error (On the line of code
indicated below).  I know that I'm probably screwing up the order of
events however I'm not sure when to set custom properties when
creating a new posting.

Protected Overrides Sub SavePlaceholderContent(ByVal e As
PlaceholderControlSaveEventArgs)
EnsureChildControls()

Try
Dim pPosting As String
pPosting = CmsHttpContext.Current.Posting.Guid
Dim getPosting As Posting

XXXXXXXXXXXXXXXXXXXXXXXx LINE WHERE ERROR IS THROWN
XXXXXXXXXXXXXXXXXXXXXXXXxxx
getPosting = CType(CmsHttpContext.Current.Searches.GetByGuid(pPosting),
Posting)
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXX

Dim valueArray As New ArrayList()

Dim xmlValue As XmlDocument = New XmlDocument()
Dim valueParentNode As XmlNode =
xmlValue.CreateElement("Values")
xmlValue.AppendChild(valueParentNode)

Dim value As ListItem
For Each value In valuelist.Items
If value.Selected = True Then
Dim valueNode As XmlNode =
xmlValue.CreateElement("Value")
valueNode.InnerText = value.Text
valueParentNode.AppendChild(valueNode)

valueArray.Add(value.Text)

End If
Next

CType(Me.BoundPlaceholder, XmlPlaceholder).XmlAsString
= xmlValue.InnerXml.ToString()

'set custom properties on the posting
If valueArray.IndexOf("Suppress Left Navigation") = -1
Then
getPosting.CustomProperties("SupressNav").Value =
"False"
Else
getPosting.CustomProperties("SupressNav").Value =
"True"
End If

If valueArray.IndexOf("Suppress Channel Content") = -1
Then
getPosting.CustomProperties("SupressPosting").Value
= "False"
Else
getPosting.CustomProperties("SupressPosting").Value
= "True"
End If

Catch ex As Exception
Dim overriddenException As Exception = New
Exception(ex.Message, ex)
Throw overriddenException
End Try
End Sub

Thanks,
Kimberley C





[ Post a follow-up to this message ]



    Re: SavePlaceholderContent  
Stefan [MSFT]


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


 
08-27-04 11:08 PM

Hi Kimberly,

you are not allowed to use CmsHttpContext inside a placeholder control
event.
You need to use the event context.

So please use e.Posting instead of CmsHttpContext.Current.Posting.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...>
MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...nagement+Server
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Kimberley" <kimsteph@aol.com> wrote in message
news:90e30dfe.0408271008.c660948@posting.google.com...
> Hi,
>
> I've created a checkbox placeholder and in the Protected Overrides Sub
> SavePlaceholderContent method I want to set Custom Properties against
> the posting based on the checkbox selections from the user.  It works
> without any problems when I edit old content however when I create new
> content I get an Invalid Cast Specified Error (On the line of code
> indicated below).  I know that I'm probably screwing up the order of
> events however I'm not sure when to set custom properties when
> creating a new posting.
>
> Protected Overrides Sub SavePlaceholderContent(ByVal e As
> PlaceholderControlSaveEventArgs)
>             EnsureChildControls()
>
>             Try
>                 Dim pPosting As String
>                 pPosting = CmsHttpContext.Current.Posting.Guid
>                 Dim getPosting As Posting
>
> XXXXXXXXXXXXXXXXXXXXXXXx LINE WHERE ERROR IS THROWN
> XXXXXXXXXXXXXXXXXXXXXXXXxxx
> getPosting = CType(CmsHttpContext.Current.Searches.GetByGuid(pPosting),
> Posting)
>
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXX
>
>                 Dim valueArray As New ArrayList()
>
>                 Dim xmlValue As XmlDocument = New XmlDocument()
>                 Dim valueParentNode As XmlNode =
> xmlValue.CreateElement("Values")
>                 xmlValue.AppendChild(valueParentNode)
>
>                 Dim value As ListItem
>                 For Each value In valuelist.Items
>                     If value.Selected = True Then
>                         Dim valueNode As XmlNode =
> xmlValue.CreateElement("Value")
>                         valueNode.InnerText = value.Text
>                         valueParentNode.AppendChild(valueNode)
>
>                         valueArray.Add(value.Text)
>
>                     End If
>                 Next
>
>                 CType(Me.BoundPlaceholder, XmlPlaceholder).XmlAsString
> = xmlValue.InnerXml.ToString()
>
>                 'set custom properties on the posting
>                 If valueArray.IndexOf("Suppress Left Navigation") = -1
> Then
>                     getPosting.CustomProperties("SupressNav").Value =
> "False"
>                 Else
>                     getPosting.CustomProperties("SupressNav").Value =
> "True"
>                 End If
>
>                 If valueArray.IndexOf("Suppress Channel Content") = -1
> Then
>                     getPosting.CustomProperties("SupressPosting").Value
> = "False"
>                 Else
>                     getPosting.CustomProperties("SupressPosting").Value
> = "True"
>                 End If
>
>             Catch ex As Exception
>                 Dim overriddenException As Exception = New
> Exception(ex.Message, ex)
>                 Throw overriddenException
>             End Try
>         End Sub
>
> Thanks,
> Kimberley C







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:39 AM.      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