2011-10-28 83 views
0

在Web應用程序中,我爲JavaScript編寫鼠標懸停和鼠標懸停按鈕來更改顏色。當按鈕處於datalist控制中時,它不起作用,當按鈕處於datalist控制之外時,它工作正常。這是我的代碼,請幫助我。ASP.NET中用於Datalist控件的JavaScript?

<script type="text/javascript" > 
function changeImage() 
{  
    document.getElementById("btnView").style.background = "#AD1F13"; 
} 

function changeImage1() 
{ 
    document.getElementById("btnView").style.background = "#005594"; 
} 
</script> 

<asp:DataList ID="dtlstMagazine" class='tableborder' runat ="server" Width ="100%" 
      onitemdatabound="dtlstMagazine_ItemDataBound" 
      onitemcommand="dtlstMagazine_ItemCommand"> 
     <ItemTemplate > 
      <div style="text-align:left; " class="item-title" > 
<asp:LinkButton Font-Underline ="false" ID="ltrlTitle" CommandName="Redirect" CommandArgument='<%# Eval("titleid") %>' Font-Bold ="true" Font-Size ="Medium"   runat="server" Text ='<%# Eval("Title") %>'></asp:LinkButton> 
             </div>        
      <asp:Button ID="Btn_CR1" runat="server" Text="Continue Reading" CssClass='button3' onMouseOver="changeImage()" onMouseOut="changeImage1()" /> </ItemTemplate> </asp:DataList> 
+0

Jaascript模式彈出網址:http://weblogs.asp.net/jeff/archive/2006/你可以改變你的JavaScript方法來做到這一點10/25/Modal_2D00_style-pops-in-Javascript-and-CSS.aspx –

回答

0

實際上,您需要引用列表中的按鈕來更改其屬性。

function changeImage(obj) 
{  
    obj.style.background = "#AD1F13"; 
} 

和你的ASPX到:

<asp:Button ID="Btn_CR1" runat="server" Text="Continue Reading" CssClass='button3' onMouseOver="changeImage(this)" onMouseOut="changeImage1(this)" /> 
+0

坦克你Waqas,它現在正在工作。 –