302班

java突击队
posts - 151, comments - 74, trackbacks - 0, articles - 14
  语源科技BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

WebControl.ToolTip 属性及用法

Posted on 2007-05-05 00:09 停留的风 阅读(1838) 评论(0)  编辑  收藏 所属分类: .NET技巧特辑
.NET Framework 类库  

WebControl.ToolTip 属性

获取或设置当鼠标指针悬停在 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>