Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

litfal
Lv 5
litfal asked in 電腦與網際網路程式設計 · 2 decades ago

ASP.Net Label觸發MouseEnter事件

ASP.Net 要如何觸發MouseEnter和MouseLeave事件並導向設定的程式碼?

使用WebControl的Label,

想當滑鼠經過他時,Label的前景文字可以變色

而離開時變回來(類似超連結)

希望能使用Code Behind

Update:

那再請問一下

如果我是要再滑鼠移入時加上底線?

我用

onmouseover="this.TEXT-DECORATION='underline' "或

onmouseover="this.style.TEXT-DECORATION='underline' "

.NET他都說我語法錯誤@@

1 Answer

Rating
  • 2 decades ago
    Favorite Answer

    只需要在aspx的頁面加css即可,例如

    <span id=test onmouseover="this.style.color='blue'"; omouseout="this.style.color=black";>

    <asp:Label id="Label1" runat="server">Label</asp:Label></span>

    2006-05-19 10:57:27 補充:

    <head><style> .mOver { FONT-SIZE: 18pt; COLOR: red; TEXT-DECORATION = underline} .mOut { color: black; font-size: 12pt; TEXT-DECORATION = none} </style> <script> function test(cssname) { document.all("test").className=cssname } </script></head>

    2006-05-19 10:58:02 補充:

    文字超,分兩次貼<body><span id="test" onmouseover="test('mOver');" onmouseout="test('mOut');"> <asp:Label id="Label1" runat="server">Label</asp:Label></span></body>

    Source(s): 自己
Still have questions? Get your answers by asking now.