Of course .. you could always just create an extender, which has a string property for the name of the template .. which you then just use in the RenderInnerScript and RenderScript overrides ...
protected override void RenderInnerScript(Microsoft.Web.Script.ScriptTextWriter writer, DragListProperties props)
{
base.RenderInnerScript(writer, props);
// The dragDropList needs two template properties to function. One is the dropCueTemplate,
// which is the "you can drop here" look, and the emptyCueTemplate which is
// shown for empty lists.
// This content will be rendered as a child tag of the behavior element.
SerializeTemplateProperty("DropCueTemplate", "dropCueTemplate", writer, props);
SerializeTemplateProperty("EmptyTemplate", "emptyTemplate", writer, props);
}
protected override void RenderScript(Microsoft.Web.Script.ScriptTextWriter writer, Control targetControl)
{
DragListProperties properties (DragListProperties)base.GetTargetProperties(targetControl);
if (properties != null)
{
writer.WriteStartElement("dragDropList");
writer.WriteAttributeString("dataType", properties.DataType);
writer.WriteAttributeString("acceptedDataTypes", properties.AcceptedDataTypes);
writer.WriteAttributeString("dragMode", properties.DragMode.ToString());
writer.WriteAttributeString("direction", "Vertical");
// Render the children elements
this.RenderInnerScript(writer, properties);
writer.WriteEndElement(); //dragDropList
}
}
private void SerializeTemplateProperty(string propertyName, string templateName, Microsoft.Web.Script.ScriptTextWriter writer, DragListProperties properties)
{
PropertyDescriptor tempLayoutProp = TypeDescriptor.GetProperties(properties)[propertyName];
string strValue = SerializePropertyToString(properties, tempLayoutProp, true);
if (strValue != null)
{
writer.WriteStartElement(templateName);
writer.WriteStartElement("template");
writer.WriteAttributeString("layoutElement", strValue);
writer.WriteEndElement(); // template
writer.WriteEndElement(); // templateName
}
}
This all works fine by the way, as I have a DropDownList implemented in this fashion.