|
Home > Archive > Microsoft Content Management Server > August 2004 > SavePlaceholderContent
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 |
SavePlaceholderContent
|
|
| Kimberley 2004-08-27, 6: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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
| |
| Stefan [MSFT] 2004-08-27, 6: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...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver
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
|
|
|
|
|