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




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

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

You can help support asp.net.ph