|
Home > Archive > Microsoft Content Management Server > September 2006 > Modifying Placeholder content Programatically
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 |
Modifying Placeholder content Programatically
|
|
| Arjuna 2006-09-28, 7:25 am |
| Hi,
Can someone tell me what is the proper way to modify Placeholder content
programatically. What I do now is something like this.
Posting p; //Posting which contains the Placeholder.
p.Placeholders[plc.Name].Datasource.RawContent = ""; //my text to put in here.
Is this the correct way or is there more to it like obtaining ownership of
the Placeholder first and so on?
Thanks
Arjuna.
| |
| Stefan [MSFT] 2006-09-28, 7:25 am |
| Hi Arjuna,
no this is not the correct way to do this.
You should never use DataSource.RawContent.
See here on how to do it correct:
http://blogs.technet.com/stefan_gos.../24/119546.aspx
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
"Arjuna" <Arjuna@discussions.microsoft.com> wrote in message
news:877DA742-AFFB-4EDF-B2A7-6BDDD59AD39D@microsoft.com...
> Hi,
>
> Can someone tell me what is the proper way to modify Placeholder content
> programatically. What I do now is something like this.
>
> Posting p; //Posting which contains the Placeholder.
> p.Placeholders[plc.Name].Datasource.RawContent = ""; //my text to put in
> here.
>
> Is this the correct way or is there more to it like obtaining ownership of
> the Placeholder first and so on?
> Thanks
> Arjuna.
| |
| Arjuna 2006-09-28, 7:25 am |
| Hi Stefan,
Thanks for the Pointer. However there is another question. I do not modify
the state of the Posting when modifying Placeholder content. That is when
modifying Placeholder content through the Console we
1. Go into edit mode
2. Do the modification
3. Save
However if you look at my code the only thing I do is just modify the
content only.
(p.Placeholders[plc.Name] as HtmlPlaceholder).Html = "My Content".
I am bypassing step 1 and step 2 in the code. Is this the correct approach.
Thanks
Arjuna.
"Stefan [MSFT]" wrote:
> Hi Arjuna,
>
> no this is not the correct way to do this.
> You should never use DataSource.RawContent.
>
> See here on how to do it correct:
> http://blogs.technet.com/stefan_gos.../24/119546.aspx
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
>
> "Arjuna" <Arjuna@discussions.microsoft.com> wrote in message
> news:877DA742-AFFB-4EDF-B2A7-6BDDD59AD39D@microsoft.com...
>
>
>
| |
| Stefan [MSFT] 2006-09-28, 7:25 am |
| Hi Arjuna,
you need to be aware that p.Placeholders[plc.Name] as HtmlPlaceholder will
return a null pointer if the placeholder is of a different type.
Then the access to the Html property will raise an null reference exception.
If you are sure about the type of the placeholder you can use this code.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
"Arjuna" <Arjuna@discussions.microsoft.com> wrote in message
news:EA5A9BA9-29D1-4EBF-99EA-7AF6B9447C42@microsoft.com...[vbcol=seagreen]
> Hi Stefan,
>
> Thanks for the Pointer. However there is another question. I do not modify
> the state of the Posting when modifying Placeholder content. That is when
> modifying Placeholder content through the Console we
> 1. Go into edit mode
> 2. Do the modification
> 3. Save
>
> However if you look at my code the only thing I do is just modify the
> content only.
>
> (p.Placeholders[plc.Name] as HtmlPlaceholder).Html = "My Content".
>
> I am bypassing step 1 and step 2 in the code. Is this the correct
> approach.
>
> Thanks
> Arjuna.
>
> "Stefan [MSFT]" wrote:
>
|
|
|
|
|