YouTip LogoYouTip

Prop Webcontrol Standard Tooltip

## ASP.NET WebControl ToolTip Property The `ToolTip` property is a standard property shared by almost all ASP.NET Web server controls. It is used to define or retrieve the helper text that appears when a user hovers their mouse pointer over the control. --- ## Definition and Usage The `ToolTip` property specifies the explanatory text displayed in a small pop-up window (often called a tooltip) when the mouse cursor hovers over a Web server control. In the rendered HTML, this property is translated into the standard HTML `title` attribute of the corresponding element (such as ``, ``, or ``), which is natively supported by all modern web browsers. --- ## Syntax ```xml ``` ### Property Values | Value | Description | | :--- | :--- | | `string` | The text to be displayed when the mouse hovers over the control. | --- ## Code Examples ### Example 1: Setting a ToolTip on a Button Control The following example demonstrates how to set the tooltip text for an ASP.NET `Button` control. When a user hovers over the "Submit" button, the text *"This is an example-button"* will be displayed. ```xml
``` ### Example 2: Setting a ToolTip Programmatically (C#) You can also set or change the `ToolTip` property dynamically in your code-behind file. **ASPX Markup:** ```xml
``` **C# Code-Behind:** ```csharp protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Label1.ToolTip = "This tooltip was set dynamically from C# code."; } } ``` --- ## Technical Considerations 1. **HTML Rendering:** When ASP.NET renders the control to the client browser, the `ToolTip` property is converted into the standard HTML `title` attribute. For example: * **ASP.NET:** `` * **Rendered HTML:** `` 2. **Accessibility (A11y):** Tooltips are highly beneficial for accessibility. Screen readers often read the `title` attribute to provide additional context to visually impaired users. 3. **Styling Limitations:** The default visual appearance (font, background color, delay time) of the native tooltip is determined by the user's operating system and web browser. If you require custom-styled tooltips, you should use CSS and JavaScript/jQuery libraries (such as Bootstrap Tooltips or Popper.js) instead of relying solely on the native `ToolTip` property.
← Prop Webcontrol Standard WidthProp Webcontrol Standard Forec β†’