Export (0) Print
Expand All

WebControl.ToolTip Property

Gets or sets the text displayed when the mouse pointer hovers over the Web server control.

[Visual Basic]
Public Overridable Property ToolTip As String
[C#]
public virtual string ToolTip {get; set;}
[C++]
public: __property virtual String* get_ToolTip();
public: __property virtual void set_ToolTip(String*);
[JScript]
public function get ToolTip() : String;
public function set ToolTip(String);

Property Value

The text displayed when the mouse pointer hovers over the Web server control. The default is String.Empty.

Remarks

Use the ToolTip property to specify the custom text that is displayed when the mouse pointer hovers over the Web server control.

Note   This property is rendered for all browsers. However, only Microsoft Internet Explorer will display this property as a ToolTip. All other browsers will ignore this property.

Example

[Visual Basic, C#, JScript] The following example illustrates how to set the ToolTip property on the Button control, which is inherited from the WebControl base class.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
 <body>
 
     <h3>ToolTip Property of a Web Control<br></h3>
 
 <script language="VB" runat="server">
 
    Sub SubmitBtn1_Click(sender As Object, e As EventArgs)
        Label1.Text = "Share your happiness with others!"
    End Sub

    Sub SubmitBtn2_Click(sender As Object, e As EventArgs)
        Label1.Text = "Don't worry, be very happy!"
    End Sub
 
 </script>
 
 <form runat=server>
 
     Don't know which button to click?
     <br>
     Move the mouse pointer over the buttons to find out!
     <p>
 
     <asp:Button id="SubmitBtn1" OnClick="SubmitBtn1_Click" 
     Text="Click Me" 
     ToolTip="Click this one if you are happy" runat="server"/>
     <p>
 
     <asp:Button id="SubmitBtn2" OnClick="SubmitBtn2_Click" 
     Text="Click Me" 
     ToolTip="Click this one if you are not too happy" runat="server"/>
     <p>
     
     <asp:Label id="Label1" Font-size=24 Font-Bold="True" BackColor="Yellow" runat="server"/>
 </form>
 
 </body>
 </html>
 

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
 <body>
 
     <h3>ToolTip Property of a Web Control<br></h3>
 
 <script language="C#" runat="server">
 
     void SubmitBtn1_Click(Object sender, EventArgs e) {
     Label1.Text = "Share your happiness with others!";
     }
 
     void SubmitBtn2_Click(Object sender, EventArgs e) {
     Label1.Text = "Don't worry, be very happy!";
     }
 
 </script>
 
 <form runat=server>
 
     Don't know which button to click?
     <br>
     Move the mouse pointer over the buttons to find out!
     <p>
 
     <asp:Button id="SubmitBtn1" OnClick="SubmitBtn1_Click" 
     Text="Click Me" 
     ToolTip="Click this one if you are happy" runat="server"/>
     <p>
 
     <asp:Button id="SubmitBtn2" OnClick="SubmitBtn2_Click" 
     Text="Click Me" 
     ToolTip="Click this one if you are not too happy" runat="server"/>
     <p>
     
     <asp:Label id="Label1" Font-size=24 Font-Bold="True" BackColor="Yellow" runat="server"/>
 </form>
 
 </body>
 </html>
 

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
 <body>
 
     <h3>ToolTip Property of a Web Control<br></h3>
 
 <script language="JSCRIPT" runat="server">
 
    function SubmitBtn1_Click(sender : Object, e : EventArgs){
        Label1.Text = "Share your happiness with others!"
    }

    function SubmitBtn2_Click(sender : Object, e : EventArgs){
        Label1.Text = "Don't worry, be very happy!"
    }
 
 </script>
 
 <form runat=server>
 
     Don't know which button to click?
     <br>
     Move the mouse pointer over the buttons to find out!
     <p>
 
     <asp:Button id="SubmitBtn1" OnClick="SubmitBtn1_Click" 
     Text="Click Me" 
     ToolTip="Click this one if you are happy" runat="server"/>
     <p>
 
     <asp:Button id="SubmitBtn2" OnClick="SubmitBtn2_Click" 
     Text="Click Me" 
     ToolTip="Click this one if you are not too happy" runat="server"/>
     <p>
     
     <asp:Label id="Label1" Font-size=24 Font-Bold="True" BackColor="Yellow" runat="server"/>
 </form>
 
 </body>
 </html>
 

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

WebControl Class | WebControl Members | System.Web.UI.WebControls Namespace

Show:
© 2014 Microsoft