Microsoft Content Management Server - Creating HTML Placeholder through PAPI

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > January 2005 > Creating HTML Placeholder through PAPI





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 Creating HTML Placeholder through PAPI
Mei Ying [MVP]

2004-12-29, 8:46 pm

Hi

Looks like you are missing a call to Databind(). Also you
may want to not set the Html property of the control on
every page load.

Check out the sample code written by Stefan that shows you
how you can add the HtmlPlaceholderControl dynamically:
http://www.gotdotnet.com/Community/...es/Details.aspx
?SampleGuid=fa1ce476-be90-443f-98d5-0a610ebda849

regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Contact: meiyinglim@hotmail.com
---
>-----Original Message-----
>I have a template in .net with a text area html control.

I get the data from
>the text area control and have to instantiate the cms

html control, set its
>properties, id, name, placeholder to bind etc in the

codebehind page. I'm
>doing this to create an UI which is same as the one that

is used although on
>a different CMS product.
> This is the code I'm using:
>
> Private Sub Page_Load(ByVal sender As System.Object,

ByVal e As
>System.EventArgs) Handles MyBase.Load
> Dim htmlPh As New
>Microsoft.ContentManagement.WebControls.HtmlPlaceholderCon

trol
>
> htmlPh.ID = "htmlPhTest1"
> htmlPh.Width.Pixel(50)
> htmlPh.Height.Pixel(100)
> htmlPh.Html = "Hello there!!"
> htmlPh.PlaceholderToBind = "myHtmlPh"
> htmlPh.AllowHtmlSourceEditing = True
> postingHeading.Text = htmlPh.ClientID()
>
>After I save the html control and its data, when I try to

edit the page, the
>html text doesnt appear in an html control. Why is that?

What am I doing
>wrong here?
> To summarize: I'm trying to get a text from an .Net web

control and assign
>it to a cms html place holder control. I'm havin

gproblems when I try to edit
>the posting.
>
>THanks for your help.
>
>V
>.
>

Varad

2004-12-30, 5:52 pm

Thanks Mei. I'm getting an error.
The error I get is: Object reference not set to an instance of an object at
at
me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add(htmlPh)").Controls.Add(htmlPh))

I added these lines to my code per Stefans code sample from Gotdotnet.com:

Dim PlaceholderControlDestination As HtmlControls.HtmlTableCell

htmlPh.DataBind()

Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add(htmlPh)
").Controls.Add(htmlPh)

Thanks for your time.

Varad



"Mei Ying [MVP]" wrote:

> Hi
>
> Looks like you are missing a call to Databind(). Also you
> may want to not set the Html property of the control on
> every page load.
>
> Check out the sample code written by Stefan that shows you
> how you can add the HtmlPlaceholderControl dynamically:
> http://www.gotdotnet.com/Community/...es/Details.aspx
> ?SampleGuid=fa1ce476-be90-443f-98d5-0a610ebda849
>
> regards
> Mei Ying
> ---
> Blog: http://meiyinglim.blogspot.com
> Contact: meiyinglim@hotmail.com
> ---
> I get the data from
> html control, set its
> codebehind page. I'm
> is used although on
> ByVal e As
> trol
> edit the page, the
> What am I doing
> control and assign
> gproblems when I try to edit
>

Stefan [MSFT]

2004-12-30, 5:52 pm

Hi Varad,

I assume you did not create a control with name
"PlaceholderControlDestination".
Without this the FindControl function will return null.

Cheers,
Stefan.


"Varad" <varasani@gmail.com> wrote in message
news:0D581491-DCEE-4427-A967-8A9E75E48443@microsoft.com...
> Thanks Mei. I'm getting an error.
> The error I get is: Object reference not set to an instance of an object

at
> at
>

me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add
(htmlPh)").Controls.Add(htmlPh))
>
> I added these lines to my code per Stefans code sample from

Gotdotnet.com:
>
> Dim PlaceholderControlDestination As HtmlControls.HtmlTableCell
>
> htmlPh.DataBind()
>
>

Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add
(htmlPh)[vbcol=seagreen]
> ").Controls.Add(htmlPh)
>
> Thanks for your time.
>
> Varad
>
>
>
> "Mei Ying [MVP]" wrote:
>


Varad

2004-12-30, 5:52 pm

Stefan I have declared it as
Dim PlaceholderControlDestination As HtmlControls.HtmlTableCell just like in
your code.

"Stefan [MSFT]" wrote:

> Hi Varad,
>
> I assume you did not create a control with name
> "PlaceholderControlDestination".
> Without this the FindControl function will return null.
>
> Cheers,
> Stefan.
>
>
> "Varad" <varasani@gmail.com> wrote in message
> news:0D581491-DCEE-4427-A967-8A9E75E48443@microsoft.com...
> at
> me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add
> (htmlPh)").Controls.Add(htmlPh))
> Gotdotnet.com:
> Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add
> (htmlPh)
>
>
>

Stefan [MSFT]

2004-12-30, 5:52 pm

But did you have such a control in the aspx or ascx file?
Just declaring it in the code behind file is not enough!
Please compare in my sample.

Cheers,
Stefan


"Varad" <varasani@gmail.com> wrote in message
news:1586FEAD-CF92-4639-A79C-315EB3B8CBEF@microsoft.com...
> Stefan I have declared it as
> Dim PlaceholderControlDestination As HtmlControls.HtmlTableCell just like

in[vbcol=seagreen]
> your code.
>
> "Stefan [MSFT]" wrote:
>
object[vbcol=seagreen]
me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add[vbcol=seagreen]
Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add[vbcol=seagreen]


Varad

2005-01-03, 5:50 pm

Hi Stefan
I forgot to declare the html control in the aspx page. that took me past
the error I got. But my problem is that I'm trying to get the html to display
in a placeholderbox when viewing in edit mode.
My suspicion is that even if save data through a html placeholder, when I
view it in edit mode, if the template that was used to create it doesnt have
an embedded CMS control, the data wont display in the control that was
created in the code behind page. Is that true?

Thanks


"Stefan [MSFT]" wrote:

> But did you have such a control in the aspx or ascx file?
> Just declaring it in the code behind file is not enough!
> Please compare in my sample.
>
> Cheers,
> Stefan
>
>
> "Varad" <varasani@gmail.com> wrote in message
> news:1586FEAD-CF92-4639-A79C-315EB3B8CBEF@microsoft.com...
> in
> object
> me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add
> Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add
>
>
>

Stefan [MSFT]

2005-01-04, 7:47 am

Hi Varad,

no this is not true.
In edit mode the ActiveX editor will show up correctly.
Try my ready-to-use sample. It will show it to you.

Cheers,
Stefan.

"Varad" <varasani@gmail.com> wrote in message
news:99027FF8-E909-4225-9539-C7BEA48347F3@microsoft.com...
> Hi Stefan
> I forgot to declare the html control in the aspx page. that took me past
> the error I got. But my problem is that I'm trying to get the html to

display
> in a placeholderbox when viewing in edit mode.
> My suspicion is that even if save data through a html placeholder, when

I
> view it in edit mode, if the template that was used to create it doesnt

have[vbcol=seagreen]
> an embedded CMS control, the data wont display in the control that was
> created in the code behind page. Is that true?
>
> Thanks
>
>
> "Stefan [MSFT]" wrote:
>
like[vbcol=seagreen]
me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add[vbcol=seagreen]
Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add[vbcol=seagreen]


Varad

2005-01-04, 7:47 am

Thanks Stefan. I'll try your sample. Can I include your control in a web app
using VB.Net?

"Stefan [MSFT]" wrote:

> Hi Varad,
>
> no this is not true.
> In edit mode the ActiveX editor will show up correctly.
> Try my ready-to-use sample. It will show it to you.
>
> Cheers,
> Stefan.
>
> "Varad" <varasani@gmail.com> wrote in message
> news:99027FF8-E909-4225-9539-C7BEA48347F3@microsoft.com...
> display
> I
> have
> like
> me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add
> Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add
>
>
>

Stefan [MSFT]

2005-01-04, 8:46 pm

Hi Varad,

it is not a control, it is a template file.
You would have to port the code behind part to VB.NET.

Cheers,
Stefan.

"Varad" <varasani@gmail.com> wrote in message
news:7E57F321-7283-4A0E-8E2E-CB85569F42AB@microsoft.com...
> Thanks Stefan. I'll try your sample. Can I include your control in a web

app[vbcol=seagreen]
> using VB.Net?
>
> "Stefan [MSFT]" wrote:
>
past[vbcol=seagreen]
when[vbcol=seagreen]
doesnt[vbcol=seagreen]
just[vbcol=seagreen]
an[vbcol=seagreen]
me.findcontrol("Me.FindControl("PlaceholderControlDestination").Controls.Add[vbcol=seagreen]
HtmlControls.HtmlTableCell[vbcol=seagreen]
Me.FindControl("Me.FindControl("PlaceholderControlDestination").Controls.Add[vbcol=seagreen]


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com