asp.net.ph

Button.Text Property

System.Web.UI.WebControls Namespace   Button Class


Sets or retrieves the text caption displayed in a Button control.

Syntax


Inline <asp:button text = strText ... >
Script Button.Text [ = strText ]

Property Value


strText String specifying the text caption displayed in the button.

The property is read/write with no default value.

Remarks

Use the Text property to specify or determine the caption to display on the Button control.

Example

The following example shows how to initially set the Text property at design time, and dynamically change the caption at run time based on user input.

<script language = "C#" runat = "server">
   void chgCaption ( Object src, EventArgs e ) {
      if ( ! ( myTextBox.Text == "" ) ) {
         myButton.Text = myTextBox.Text;
      }
   }
</script>

<form runat = "server">
   <p>Enter the caption you want for the Button. </p>

   <p><asp:textbox id = "myTextBox" runat = "server" />

   <p><asp:button id = "myButton" runat = "server" text = "Submit" 
      onClick = "chgCaption" />
</form>
  C# VB

 Show me 

See Also

Button Members Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note