我有一个ASP.NET应用程序并使用ListView
。此ListView
包含行和列。列是姓名,姓氏,电子邮件等...此Control
中的每个ListView
都是LinkButton
。
我的想法:
如果用户将鼠标移到LinkButton
上,我希望他们在该行上看到不同的BackroundColor
。
例如:
我的代码:
ASPX:
<body>
<form id="form1" runat="server">
<div class="header">
<br />
<table id="SuchTabelle" runat="server" border="0">
<tr>
<th><asp:Label ID="id_SearchUser" runat="server" Text="lblSearchUser"></asp:Label></th>
<th><asp:TextBox ID="txtBenutzer" runat="server" Width="250px"></asp:TextBox></th>
<th></th>
</tr>
<tr>
<th><asp:Label ID="id_location" runat="server" Text="lblLocation"></asp:Label></th>
<th><asp:DropDownList ID="dropWerk" runat="server" Width="250px" /></th>
<th><asp:Button ID="Button2" runat="server" Text="Suchen"
onclick="btnBenutzerSuchen_Click" Width="250" /></th>
</tr>
</table>
<br />
<br />
<b> Info:</b>
<asp:Label ID="lbMeldung" runat="server"
Text="Geben Sie den Kontakt ein, nachdem gesucht werden soll..."></asp:Label>
<br />
<br />
</div>
<div class="bodyList">
<asp:ListView runat="server" ID="myListView">
<LayoutTemplate>
<table id="UserTable" runat="server" border="0">
<tr id="Tr1" style="background-color:#E5E5FE">
<th runat="server"><asp:LinkButton ID="lnkBenutzer" runat="server" >id_Benutzer</asp:LinkButton></th>
<th runat="server"><asp:LinkButton ID="lnkemail" runat="server" >id_Email</asp:LinkButton></th>
<th runat="server"><asp:LinkButton ID="lnkVorname" runat="server" >id_Vorname</asp:LinkButton></th>
<th runat="server"><asp:LinkButton ID="lnkNachname" runat="server" >id_Nachname</asp:LinkButton></th>
<th runat="server"><asp:LinkButton ID="lnkTelefon" runat="server" >id_Telefon</asp:LinkButton></th>
</tr>
<tr runat="server" id="ItemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color:#EFEFEF">
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
<br />
<br />
</div>
</form>
</body>
答案 0 :(得分:1)
您可以使用CSS:
<LayoutTemplate>
<table id="UserTable" runat="server" class="myClass">
<tr id="Tr1" class="myClass">
<th id="Th1" runat="server">
<asp:LinkButton ID="lnkBenutzer" runat="server" Text="id_Benutzer" />
</th>
<th id="Th2" runat="server">
<asp:LinkButton ID="lnkemail" runat="server" Text="id_Email" />
</th>
<th id="Th3" runat="server">
<asp:LinkButton ID="lnkVorname" runat="server" Text="id_Vorname" />
</th>
<th id="Th4" runat="server">
<asp:LinkButton ID="lnkNachname" runat="server" Text="id_Nachname" />
</th>
<th id="Th5" runat="server">
<asp:LinkButton ID="lnkTelefon" runat="server" Text="id_Telefon" />
</th>
</tr>
<tr runat="server" id="ItemPlaceholder">
</tr>
</table>
</LayoutTemplate>
并在* .css文件中:
.myClass
{
}
.myClass:hover
{
background-color: Green;
}