Skip to content

ViewComponentBase

Root abstraction for server-rendered fluent UI components; owns Render()/ToHtmlString() plumbing that wraps the view's writer in an HtmlTextWriter and calls the derived type's WriteHtml, but its own WriteHtml is an empty virtual, so any derived type that doesn't override it renders nothing.

Purpose

  • Root abstraction for server-rendered fluent UI components; owns Render()/ToHtmlString() plumbing that wraps the view's writer in an HtmlTextWriter and calls the derived type's WriteHtml, but its own WriteHtml is an empty virtual, so any derived type that doesn't override it renders nothing.

Context

  • Namespace: SAIF.Web.Mvc.UI
  • Assembly/package: SAIF.Framework.Web.Mvc (source-shipping NuGet package)
  • Kind: abstract class

Public members

Member Signature Purpose
HtmlAttributes public IDictionary<string, object> HtmlAttributes { get; } Attribute dictionary applied to the component's root element.
Id public string Id { get; set; } Element id of the rendered component.
Name public string Name { get; set; } Component name, used for element naming.
ViewContext public ViewContext ViewContext { get; } The MVC view context the component renders into.
Render() public void Render() Writes the component's markup to ViewContext.Writer by invoking WriteHtml.
ToHtmlString() public string ToHtmlString() Returns the component's markup as a string instead of writing it.
WriteHtml(HtmlTextWriter) protected virtual void WriteHtml(HtmlTextWriter writer) Empty in this base class; derived types must override it to emit markup.

Behavioral notes

  • Toolbar (the only concrete derived type in this library) does not override WriteHtml with real markup — it only calls base.WriteHtml, so rendering a Toolbar currently emits no output (see OP-23).

Sources

  • src/Web.Mvc/UI/ViewComponentBase.cs