获取或设置当鼠标指针悬停在 Web 服务器控件上时显示的文本。
[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);
属性值
当鼠标指针悬停在 Web 服务器控件上时显示的文本。默认值为 String.Empty。
备注
使用 ToolTip 属性指定当鼠标指针悬停在 Web 服务器控件上时显示的自定义文本。
注意 对于所有的浏览器都呈现此属性。然而,只有 Microsoft Internet Explorer 将此属性显示为工具提示。其他所有的浏览器都忽略此属性。
示例
[Visual Basic, C#, JScript] 下面的示例阐释如何设置从 WebControl 基类继承的 Button 控件的 ToolTip 属性。
[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>