Friday, June 26, 2015

Ektron Smart Forms - rich text field outputs as "Rich"

When using the XSD output of an Ektron smart form and converting this to a C#/VB class, rich text content will generally output as the string "Rich". This is because rich text is not a standard .NET data type, and it will need a small fix to work correctly. In the class file (generated by XSD.exe) look for the rich class - "public partial class rich".

We are going to add in the following ToString extension which will give us the correct rich text.
public partial class rich {
    private System.Xml.XmlNode[] anyField;
    /// <remarks/>
    public System.Xml.XmlNode[] Any {
        get {
            return this.anyField;
        set {
            this.anyField = value;

    public override string ToString()
        StringBuilder sb = new StringBuilder();

        foreach (XmlNode item in this.anyField)

        return sb.ToString();
Simply add in the "public override string ToString()" method and the rich text will begin to render correctly.

No comments:

Post a Comment