OutputText
OutputText is a lightweight server‑side control used primarily in Web Forms applications to render text to a web page. It derives from the base class WebControl and implements the IRenderControl interface, providing a minimal set of properties and methods for displaying literal text. The control’s text can be set through its Text property, which accepts a string that will be HTML‑encoded before rendering unless the HtmlEncode property is explicitly set to false. OutputText is often employed within data‑binding scenarios, where the control’s Text property is bound to a database field, allowing dynamic display of information such as titles, labels, or results of a calculation.
Because the control produces no additional markup beyond the encoded text, it is ideal for situations that
Unlike more feature‑rich controls like Label or Literal, OutputText offers a narrower API, with fewer properties
<asp:OutputText ID="OutputText1" runat="server" Text="Hello, World!" />
In code‑behind, a value can be assigned or changed during the page lifecycle:
OutputText1.Text = GetGreeting();
Keep in mind that because OutputText performs automatic HTML encoding, it is safe for displaying user‑generated