System.Web.UI.WebControls Namespace Button Class
Sets or retrieves the text caption displayed in a Button control.
Inline |
<asp:button text = strText ... > |
Script |
Button.Text [ = strText ] |
strText |
String specifying the text caption displayed in the button. |
The property is read/write with no default value.
Use the Text property to specify or determine the caption to display on the Button control.
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>
<script language = "VB" runat = "server">
Sub chgCaption ( src As Object, e As EventArgs )
If Not myTextBox.Text = "" Then
myButton.Text = myTextBox.Text
End If
End Sub
</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
Button Members