YouTip LogoYouTip

Prop Webcontrol Linkbutton Text

## ASP.NET LinkButton Text Property The `Text` property is a fundamental property of the ASP.NET Web Server `LinkButton` control. It is used to get or set the text caption displayed on the link button. --- ## Definition and Usage The `Text` property specifies the text that appears as a hyperlink on the webpage. While a `LinkButton` looks exactly like a standard `HyperLink` control, it behaves like a standard `Button` control. Instead of navigating directly to another URL, clicking a `LinkButton` submits the form back to the server (performs a postback) and triggers server-side events. --- ## Syntax ```xml ``` ### Property Values | Property Value | Description | | :--- | :--- | | `string` | A string value representing the text displayed on the `LinkButton` control. | --- ## Code Examples ### Example 1: Setting the Text Property Declaratively The following example demonstrates how to set the `Text` property directly in the `.aspx` markup: ```xml
``` ### Example 2: Setting and Modifying the Text Property Programmatically You can also dynamically change the `Text` property of a `LinkButton` in your code-behind file (C#) during runtime: **ASPX Markup:** ```xml


``` **C# Code-Behind:** ```csharp protected void lnkSubmit_Click(object sender, EventArgs e) { // Change the LinkButton text dynamically after it is clicked lnkSubmit.Text = "Submitted!"; lblMessage.Text = "The form has been successfully processed."; } ``` --- ## Key Considerations 1. **HTML Encoding:** By default, ASP.NET automatically HTML-encodes the value of the `Text` property. If you need to include HTML tags (like `` or ``) inside your link button, you should place the HTML tags directly between the opening and closing tags of the control instead of using the `Text` attribute: ```xml Click Here ``` 2. **Empty Text:** If the `Text` property is empty and no inner content is provided between the control's opening and closing tags, the `LinkButton` will render as an empty anchor tag (``) and will be invisible to the user. 3. **Accessibility:** Always ensure that the string assigned to the `Text` property is descriptive enough for screen readers to provide a good user experience for visually impaired users.
← Prop Webcontrol Linkbutton ValProp Webcontrol Linkbutton Pos β†’

YouTip © 2024-2026 | Home | Learn Technology, Build Dreams!

All content is for educational and learning purposes only.