MCMS 2002 has a XML placeholder definition object but there is no XML placeholder Web Control shipped with the product. Woodgrove Sample MCMS website comes with a XML placeholder control but it real annoying in the sense that you only have 10 rows of text visible at a time. It is common requirement to customize the XML placeholder feel and look and also the functionality. Here is source for the XML placeholder Control that you can use as it is or customize it according to your needs ....
Just Add the following class in to your C# class library. After compiling the code you can add this XMLPlaceholder Control by right clicking on your toolbar in Visual Studio design mode and selecting Add/Remove Item. Select the Class library that contains following Class and Control is available just like HtmlPlaceholder ....
using System;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Drawing ;
using
System.Xml.XPath ;
using
System.Xml.Xsl ;
using
System.IO;
using
System.ComponentModel ;
using
Microsoft.ContentManagement.WebControls ;
using
Microsoft.ContentManagement.Publishing.Extensions.Placeholders ;
using
McmsWebControlLibrary.PlaceholderControls;
namespace
Jawad.Cms.CustomPlaceholders
{
///
/// Summary description for XMLPlaceholderControl.
///
[ToolboxData("<{0}:XMLPlaceholder runat=server>{0}:XMLPlaceholder>")]
public class XMLPlaceholder : BasePlaceholderControl
{
// Methods
public XMLPlaceholder()
{
this.McmsXmlControlHelper = new McmsXmlControlHelper();
}
protected override void CreateAuthoringChildControls(BaseModeContainer authorContainer)
{
this.tbxXmlContent = new TextBox();
this.tbxXmlContent.Height = (Unit) Unit.Parse (TextBoxHeight);
this.tbxXmlContent.Columns = TextBoxColumns;
this.tbxXmlContent.TextMode = TextBoxMode.MultiLine;
this.tbxXmlContent.Wrap = true;
this.tbxXmlContent.BackColor = Color.LightGray;
authorContainer.Controls.Add(
this.tbxXmlContent);
}
protected override void CreatePresentationChildControls(BaseModeContainer presentationContainer)
{
this.lblXmlContent = new Label();
this.lblXmlContent.BackColor = Color.LightGray;
presentationContainer.Controls.Add(
this.lblXmlContent);
}
protected override void LoadPlaceholderContentForAuthoring(PlaceholderControlEventArgs e)
{
this.EnsureChildControls();
try
{
XmlPlaceholder placeholder1 = (XmlPlaceholder)
base.BoundPlaceholder;
string text1 = placeholder1.XmlAsString;
this.tbxXmlContent.Text = text1;
}
catch (Exception exception1)
{
string text2 = exception1.Message;
}
}
protected override void LoadPlaceholderContentForPresentation(PlaceholderControlEventArgs e)
{
this.EnsureChildControls();
try
{
XmlPlaceholder placeholder1 = (XmlPlaceholder)
base.BoundPlaceholder;
string text1 = placeholder1.XmlAsString;
XPathDocument document1 =
this.McmsXmlControlHelper.CreateXPathDoc(text1);
string text2 = this.Transform(document1);
this.lblXmlContent.Text = text2;
}
catch (Exception exception1)
{
string text3 = exception1.Message;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected override void OnPopulatingDefaultContent(PlaceholderControlCancelEventArgs e)
{
try
{
this.tbxXmlContent.Text = "Enter XML";
}
catch (Exception exception1)
{
string text2 = exception1.Message;
}
}
protected override void SavePlaceholderContent(PlaceholderControlSaveEventArgs e)
{
try
{
XmlPlaceholder placeholder1 = (XmlPlaceholder)
base.BoundPlaceholder;
if (!placeholder1.Equals(null))
{
placeholder1.XmlAsString =
this.tbxXmlContent.Text.ToString();
}
}
catch (Exception exception1)
{
string text1 = exception1.Message;
}
}
private string Transform(XPathDocument xmlDoc)
{
string text3;
try
{
string text1 = "";
if (!this.XsltStylesheet.Equals(string.Empty))
{
XslTransform transform1 =
new XslTransform();
string text2 = this.Context.Server.MapPath(this.XsltStylesheet);
transform1.Load(text2);
StringWriter writer1 =
new StringWriter();
XPathNavigator navigator1 = xmlDoc.CreateNavigator();
transform1.Transform(navigator1, (XsltArgumentList)
null, writer1);
text1 = writer1.GetStringBuilder().ToString();
}
text3 = text1;
}
catch (Exception exception1)
{
string text4 = exception1.Message;
text3 = "";
}
return text3;
}
// Properties
[Bindable(
true), Browsable(true), Category("Appearance")]
public string XsltStylesheet
{
get
{
string text1 = (string) this.ViewState["XsltStylesheet"];
if (text1 != null)
{
return text1;
}
return string.Empty;
}
set
{
this.ViewState["XsltStylesheet"] = value;
}
}
[Bindable(
true), Browsable(true), Category("Appearance")]
public string TextBoxHeight
{
get
{
string text1 = (string) this.ViewState["TextBoxHeight"];
if (text1 != null)
{
return text1;
}
return "400";
}
set
{
this.ViewState["TextBoxHeight"] = value;
}
}
[Bindable(
true), Browsable(true), Category("Appearance")]
public int TextBoxColumns
{
get
{
object columns = this.ViewState["TextBoxColumns"];
if (columns != null)
{
return (int)columns;
}
return 150;
}
set
{
this.ViewState["TextBoxColumns"] = value;
}
}
// Fields
private Label lblXmlContent;
private McmsXmlControlHelper McmsXmlControlHelper;
private TextBox tbxXmlContent;
}
}