Your UIElement
classes need to implement the IHtmlString
interface. This interface's ToHtmlString
method gets called by Razor and should return an HTML-encoded string.
So I would implement this on the abscract base UIElement
and create RenderHtml
method which can be implemented by the concrete LinkButton
, etc. classes:
public abstract class UIElement : IHtmlString
{
public string ToHtmlString()
{
return RenderHtml(); // This should return an HTML-encoded string.
}
public override string ToString()
{
return ToHtmlString();
}
protected abstract string RenderHtml();
}
If you check KendoUI in Reflector/JustDecompile/dotPeek in the WidgetBase
class you will see the same pattern.