|
Home > Archive > Microsoft Content Management Server > February 2006 > How to save values to XmlPlaceholder
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 |
How to save values to XmlPlaceholder
|
|
| Crystal 2006-02-20, 5:52 pm |
| Hi there,
Can I save some values to an XmlPlaceholder on authoring page without
creating a custom placeholder control.
I try to do like this:
protected void btnAdd_Click(object sender, EventArgs e)
{
CmsHttpContext cms = CmsHttpContext.Current;
Posting p = cms.Posting;
XmlPlaceholder ph;
ph = p.Placeholders["ItemList"] as XmlPlaceholder;
ph.XmlAsString = Textbox.Text;
cms.CommitAll();
}
But the values are not saved when I click "Save and Exit".
Can anybody give some comments?
Thanks
| |
| Mei Ying [MVP] 2006-02-20, 8:48 pm |
| Hi
There are several ways to do this. Creating a custom placeholder control is
one possible solution. You could also consider:
1. Placing the code in the posting event handler.
2. Create a custom "Save and Exit" button
But the solution that you are proabably looking for is to use the template
file's SavePostingEvent handler. Here's how you can do this. In the template
file add to the OnInit() event handler:
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
// Register new event being called during save
WebAuthorContext.Current.SavePostingEvent += new
WebAuthorPostingEventHandler(SaveXmlPlac
eholderContent);
}
And add the code that does the work to the custom
SaveXmlPlaceholderContent() method:
function SaveXmlPlaceholderContent(object sender, WebAuthorPostingEventArgs e)
{
Posting p = e.Posting;
XmlPlaceholder ph;
ph = p.Placeholders["ItemList"] as XmlPlaceholder;
ph.XmlAsString = Textbox.Text;
}
--
regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---
"Crystal" wrote:
> Hi there,
> Can I save some values to an XmlPlaceholder on authoring page without
> creating a custom placeholder control.
> I try to do like this:
> protected void btnAdd_Click(object sender, EventArgs e)
> {
> CmsHttpContext cms = CmsHttpContext.Current;
> Posting p = cms.Posting;
> XmlPlaceholder ph;
> ph = p.Placeholders["ItemList"] as XmlPlaceholder;
> ph.XmlAsString = Textbox.Text;
> cms.CommitAll();
> }
> But the values are not saved when I click "Save and Exit".
>
> Can anybody give some comments?
> Thanks
>
|
|
|
|
|