WebControl.ToolTip Proprietà

Definizione

Ottiene o imposta il testo visualizzato quando il puntatore del mouse viene posizionato sul controllo server Web.

public:
 virtual property System::String ^ ToolTip { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public virtual string ToolTip { get; set; }
public virtual string ToolTip { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.ToolTip : string with get, set
member this.ToolTip : string with get, set
Public Overridable Property ToolTip As String

Valore della proprietà

Testo visualizzato quando il puntatore del mouse viene posizionato sul controllo server Web. Il valore predefinito è Empty.

Attributi

Esempio

Nell'esempio seguente viene illustrato come impostare la ToolTip proprietà sul Button controllo, ereditata dalla WebControl classe base.

Nota

L'esempio di codice seguente usa il modello di codice a file singolo e potrebbe non funzionare correttamente se copiato direttamente in un file code-behind. Questo esempio di codice deve essere copiato in un file di testo vuoto con estensione aspx. Per altre informazioni sul modello di codice Web Forms, vedere Web Forms ASP.NET Page Code Model.

<%@ 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 SubmitBtn_Click(object sender, EventArgs e)
    {
        if (((Button)sender).CommandArgument == "1")
            Label1.Text = "Share your happiness!";
        else
            Label1.Text = "Be happy!";

        Label1.BorderColor = System.Drawing.Color.BurlyWood;
        Label1.BorderWidth = 4;
    }
 
 </script>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
    <title>WebControl.ToolTip Example</title>
 </head>
 <body>
 <form id="Form1" runat="server">
 
    <h3>ToolTip Property of a Web Control</h3>
    <p>Don't know which button to click?<br />
        Move the mouse pointer over the buttons to find out!
    </p>

    <p><asp:Button id="SubmitBtn1" OnClick="SubmitBtn_Click" 
            Text="Click Me" CommandArgument="1"
            ToolTip="Click me if you are happy" runat="server"/>
    </p>

    <p><asp:Button id="SubmitBtn2" OnClick="SubmitBtn_Click" 
            Text="Click Me" CommandArgument="2"
            ToolTip="Click me if you are sad." runat="server"/>
    </p>

    <asp:Label id="Label1" Font-size="24pt" Font-Bold="True" 
        BackColor="Yellow" runat="server"/>

 </form>
 
 </body>
 </html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <script language="VB" runat="server">
 
    Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
        If CType(sender, Button).CommandArgument = "1" Then
            Label1.Text = "Share your happiness!"
        Else
            Label1.Text = "Be happy!"
        End If
        Label1.BorderColor = Drawing.Color.BurlyWood
        Label1.BorderWidth = 4
    End Sub
 
 </script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
 <head runat="server">
    <title>ToolTip Property of a Web Control</title>
</head>
<body>
  
 <form id="form1" runat="server">
 
    <h3>ToolTip Property of a Web Control</h3>
    <p>Don't know which button to click?<br />
        Move the mouse pointer over the buttons to find out!
    </p>

    <p><asp:Button id="SubmitBtn1" OnClick="SubmitBtn_Click" 
            Text="Click Me" CommandArgument="1"
            ToolTip="Click me if you are happy" runat="server"/>
    </p>

    <p><asp:Button id="SubmitBtn2" OnClick="SubmitBtn_Click" 
            Text="Click Me" CommandArgument="2"
            ToolTip="Click me if you are sad." runat="server"/>
    </p>

    <asp:Label id="Label1" Font-size="24pt" Font-Bold="True" 
        BackColor="Yellow" runat="server"/>

 </form>
 
 </body>
 </html>

Commenti

Utilizzare la ToolTip proprietà per specificare il testo personalizzato visualizzato quando il puntatore del mouse passa il puntatore del mouse sul controllo server Web.

Nota

Questa proprietà viene eseguita per tutti i browser. Tuttavia, solo Microsoft Internet Explorer visualizzerà questa proprietà come descrizione comando. Tutti gli altri browser ignorano questa proprietà.

Il valore di questa proprietà, quando impostato, può essere salvato automaticamente in un file di risorse usando uno strumento di progettazione. Per altre informazioni, vedere LocalizableAttributee Globalizzazione e Localizzazione.

Si applica a

Vedi anche