Wednesday, March 21, 2012

Write Xml/Script in Server Side

Hi,

Is there any way to wite the Xml/Script other than the XmlWriter. I mean is there any sever side objet model of atlas which I can utilize to generate these scripts.

You could create your own custom ATLAS control implementing the RenderScript method of the IScriptControl interface. For instance the following implementation:

public void RenderScript(ScriptTextWriter writer)
{
//Outputs <control> tag
GenericScriptComponent gsc = new GenericScriptComponent(new ScriptTypeDescriptor("control", ScriptNamespace.Default));
//Outputs <behaviors> tag
gsc.ID = this.ClientID;
GenericScriptComponent draggableBehavior = new GenericScriptComponent(new ScriptTypeDescriptor("draggableListItem", ScriptNamespace.Default));
draggableBehavior.AddValueProperty("handle", this.ClientID);
gsc.AddCollectionItem("behaviors", draggableBehavior);
((IScriptObject)gsc).RenderScript(writer);
}

will output the following XML-Script:

<control id="webPart1">
<behaviors>
<draggableListItem handle="webPart1Title" />
</behaviors>
</control>

No comments:

Post a Comment