Microsoft Content Management Server - Retrieving HTML from Placeholder

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > March 2007 > Retrieving HTML from Placeholder





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 Retrieving HTML from Placeholder
John

2007-03-07, 7:18 pm

I have read the posts on this topic, but I'm missing something. I have
a non-cms page on my site that I want to pull html out of a posting
but I can't get the caste change to work.

Please tell me what I'm doing wrong.

*With this code, I get the error:" Value of type
'Microsoft.ContentManagement.Publishing.Placeholder' cannot be
converted to
'Microsoft.ContentManagement.WebControls.HtmlPlaceholderControl'."

*Also, this posting was created with a Telerik Rad Edito
HTMLPlaceholder

Private Sub GetCMSContent(ByVal pstrPostingName As String)
Dim phCMS As New
Microsoft.ContentManagement.WebControls.HtmlPlaceholderControl
Dim channel As Channel
Dim posting As Posting


channel = CmsHttpContext.Current.Searches.GetByPath("/channels/
yew")
For Each posting In channel.Postings
If posting.Name.ToLower.Equals(pstrPostingName.ToLower)
Then
phCMS = posting.Placeholders("phRadContent") <-----
ERROR HERE
Me.litCartCMSHTML.Text = phCMS.Html
Exit For
End If
Next
End Sub

Thanks,

John

John

2007-03-07, 7:18 pm

Just another note, I have tried
phCMS = CType(posting.Placeholders("phRadContent"),
Microsoft.ContentManagement.WebControls.HtmlPlaceholderControl)

and I get the same error.

* The error is a "hover error" in Visual Studio, not a compile or run-
time error.


On Mar 7, 4:44 pm, "John" <john....@milliken.com> wrote:
> I have read the posts on this topic, but I'm missing something. I have
> a non-cms page on my site that I want to pull html out of a posting
> but I can't get the caste change to work.
>
> Please tell me what I'm doing wrong.
>
> *With this code, I get the error:" Value of type
> 'Microsoft.ContentManagement.Publishing.Placeholder' cannot be
> converted to
> 'Microsoft.ContentManagement.WebControls.HtmlPlaceholderControl'."
>
> *Also, this posting was created with a Telerik Rad Edito
> HTMLPlaceholder
>
> Private Sub GetCMSContent(ByVal pstrPostingName As String)
> Dim phCMS As New
> Microsoft.ContentManagement.WebControls.HtmlPlaceholderControl
> Dim channel As Channel
> Dim posting As Posting
>
> channel = CmsHttpContext.Current.Searches.GetByPath("/channels/
> yew")
> For Each posting In channel.Postings
> If posting.Name.ToLower.Equals(pstrPostingName.ToLower)
> Then
> phCMS = posting.Placeholders("phRadContent") <-----
> ERROR HERE
> Me.litCartCMSHTML.Text = phCMS.Html
> Exit For
> End If
> Next
> End Sub
>
> Thanks,
>
> John



Stefan Goßner [MSFT]

2007-03-08, 7:23 am

Hi John,

you need to cast for HtmlPlaceholder and define phCMS as HtmlPlaceholder.
Not as HtmlPlaceholderControl.

Cheers,
Stefan


"John" <john.way@milliken.com> wrote in message
news:1173304741.880588.165960@p10g2000cwp.googlegroups.com...
> Just another note, I have tried
> phCMS = CType(posting.Placeholders("phRadContent"),
> Microsoft.ContentManagement.WebControls.HtmlPlaceholderControl)
>
> and I get the same error.
>
> * The error is a "hover error" in Visual Studio, not a compile or run-
> time error.
>
>
> On Mar 7, 4:44 pm, "John" <john....@milliken.com> wrote:
>
>



John

2007-03-08, 1:18 pm

OK, I was using the wrong namespace. I should have been looking in
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlacehol=
der.

However, the HTML I got back was not what I expected. I was hoping
that this method would bring back clean HTML versus using the
rawcontent method. This content was created by a telerik control so I
have "~" everywhere.

To solve this problem, I tried the follwoing code, but I'm not getting
anything back from the phRad.HTML call. Can you help?

Private Function GetCMSContent(ByVal pstrPostingName As String, ByVal
pstrPlaceholderName As String, ByVal pstrChannelPath As String) As
String
Dim phCMS As
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlacehol=
der
Dim phRad As New
Telerik.WebControls.RadEditorPlaceHolderControl
Dim channel As Channel
Dim posting As Posting
Dim strContent As String =3D ""


channel =3D
CmsHttpContext.Current.Searches.GetByPath(pstrChannelPath)
If Not IsNothing(channel) Then
For Each posting In channel.Postings
If
posting.Name.ToLower.Equals(pstrPostingName.ToLower) Then
phCMS =3D
posting.Placeholders.Item(pstrPlaceholderName)
phRad.BoundPlaceholder =3D phCMS
phRad.DataBind()
strContent =3D phRad.Html
Exit For
End If
Next
End If
Return strContent
End Function

Thanks,
John

On Mar 8, 2:35 am, "Stefan Go=DFner [MSFT]"
<stef...@online.microsoft.com> wrote:[vbcol=seagreen]
> Hi John,
>
> you need to cast for HtmlPlaceholder and define phCMS as HtmlPlaceholder.
> Not as HtmlPlaceholderControl.
>
> Cheers,
> Stefan
>
> "John" <john....@milliken.com> wrote in message
>
> news:1173304741.880588.165960@p10g2000cwp.googlegroups.com...
>
>
>
>
>
>
>
>
>
ls/[vbcol=seagreen]
>
>


Stefan Goßner [MSFT]

2007-03-08, 1:18 pm

Hi John,

do just this:

string content = phCMS.Html.Replace("~LT~","<").Replace("~GT~",">")

(this is C# code. You need to translate it into VB.NET)

Cheers,
Stefan



"John" <john.way@milliken.com> wrote in message
news:1173371797.500393.313240@n33g2000cwc.googlegroups.com...
OK, I was using the wrong namespace. I should have been looking in
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlaceholder.

However, the HTML I got back was not what I expected. I was hoping
that this method would bring back clean HTML versus using the
rawcontent method. This content was created by a telerik control so I
have "~" everywhere.

To solve this problem, I tried the follwoing code, but I'm not getting
anything back from the phRad.HTML call. Can you help?

Private Function GetCMSContent(ByVal pstrPostingName As String, ByVal
pstrPlaceholderName As String, ByVal pstrChannelPath As String) As
String
Dim phCMS As
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlaceholder
Dim phRad As New
Telerik.WebControls.RadEditorPlaceHolderControl
Dim channel As Channel
Dim posting As Posting
Dim strContent As String = ""


channel =
CmsHttpContext.Current.Searches.GetByPath(pstrChannelPath)
If Not IsNothing(channel) Then
For Each posting In channel.Postings
If
posting.Name.ToLower.Equals(pstrPostingName.ToLower) Then
phCMS =
posting.Placeholders.Item(pstrPlaceholderName)
phRad.BoundPlaceholder = phCMS
phRad.DataBind()
strContent = phRad.Html
Exit For
End If
Next
End If
Return strContent
End Function

Thanks,
John

On Mar 8, 2:35 am, "Stefan Goßner [MSFT]"
<stef...@online.microsoft.com> wrote:[vbcol=seagreen]
> Hi John,
>
> you need to cast for HtmlPlaceholder and define phCMS as HtmlPlaceholder.
> Not as HtmlPlaceholderControl.
>
> Cheers,
> Stefan
>
> "John" <john....@milliken.com> wrote in message
>
> news:1173304741.880588.165960@p10g2000cwp.googlegroups.com...
>
>
>
>
>
>
>
>
>
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com