Button.Text Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta la didascalia di testo visualizzata nel controllo Button.
public:
property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string Text { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Text : string with get, set
Public Property Text As String
Valore della proprietà
La didascalia di testo visualizzata nel controllo Button. Il valore predefinito è Empty.
Implementazioni
- Attributi
Esempio
Nell'esempio di codice seguente viene illustrato come utilizzare la Text proprietà per specificare il didascalia visualizzato nel Button controllo .
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Manually register the event-handling method for
// the Click event of the Button control.
Button1.Click += new EventHandler(this.GreetingBtn_Click);
}
void GreetingBtn_Click(Object sender,
EventArgs e)
{
// When the button is clicked,
// change the button text, and disable it.
Button clickedButton = (Button)sender;
clickedButton.Text = "...button clicked...";
clickedButton.Enabled = false;
// Display the greeting label text.
GreetingLabel.Visible = true;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Simple Button Example</h3>
<asp:Button id="Button1"
Text="Click here for greeting..."
OnClick="GreetingBtn_Click"
runat="server"/>
<br />
<br />
<asp:Label ID="GreetingLabel" runat="server"
Visible="false" Text="Hello World!" />
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub GreetingBtn_Click(ByVal sender As Object, _
ByVal e As EventArgs)
' When the button is clicked,
' change the button text, and disable it.
Dim clickedButton As Button = sender
clickedButton.Text = "...button clicked..."
clickedButton.Enabled = False
' Display the greeting label text.
GreetingLabel.Visible = True
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Button Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Simple Button Example</h3>
<asp:Button id="Button1"
Text="Click here for greeting..."
OnClick="GreetingBtn_Click"
runat="server"/>
<br />
<br />
<asp:Label ID="GreetingLabel" runat="server"
Visible="false" Text="Hello World!" />
</div>
</form>
</body>
</html>
Commenti
Utilizzare la Text proprietà per specificare o determinare il didascalia da visualizzare nel Button controllo .
Il valore di questa proprietà, se impostato, può essere salvato automaticamente in un file di risorse usando uno strumento di progettazione. Per altre informazioni, vedere LocalizableAttributeGlobalizzazione e localizzazione.
Si applica a
Vedi anche
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per