2011-01-31 16 views
0

私はWebフォームを持っていて、データベースからランタイムで動的に作成されたテーブルに画像(imagebutton)を追加しました...静的画像があり、それは動的画像...ここ画像を追加ボタンmouseoverイベント

コードです:

HtmlTable tbProductImage = new HtmlTable(); 
        HtmlTableRow trImageRow = new HtmlTableRow(); 
        for (int j = 0; j < columnCount; j++) { 
         if (filteredFileList.Count != 0) { 
          HtmlTableCell tdImageRow = new HtmlTableCell(); 
          Panel panel = new Panel(); 
          ImageButton btnProduct = new ImageButton();       
          btnProduct.ID = "btn" + filteredFileList[j].Name.Substring(0, filteredFileList[j].Name.LastIndexOf(".")); 
          btnProduct.ImageUrl = @"/ysyp/Images/Products/" + filteredFileList[j].Name; 
          btnProduct.Width = 50; 
          btnProduct.CommandName = "Click"; 
          Page.ClientScript.GetPostBackEventReference(btnProduct, "btnProduct_Click"); 
          btnProduct.CommandArgument = filteredFileList[j].Name; 
          btnProduct.Click += new ImageClickEventHandler(btnProduct_Click); 
          panel.Controls.Add(btnProduct); 
          trImageRow.Cells.Add(tdImageRow); 
          tdImageRow.Controls.Add(panel); 
         } 
        } 
        tbProductImage.Rows.Add(trImageRow); 
        tdProduct.Controls.Add(tbProductImage); 

私はこれをどのように行うことができます...

は...

答えて

0

使用CSS擬似セレクターhoverをお願いします。

は、あなたのIMAGEBUTTONにクラスを追加します。誰もがフォーマットされたコードたい場合

hoveredButton:hover{background-image:url('path-to-your-image')} 
+0

THXをではなく、正確に私が最初に必要とするすべての私の画像動的なIMフォルダからそれらを得る... –

0

btnProduct.CssClass = "hoveredButton"; 

は、あなたのCSSのhoverButtonクラスを定義し

HtmlTable tbProductImage = new HtmlTable(); 
HtmlTableRow trImageRow = new HtmlTableRow(); 
for (int j = 0; j < columnCount; j++) 
{ 
    if (filteredFileList.Count != 0) 
    { 
     HtmlTableCell tdImageRow = new HtmlTableCell(); 
     Panel panel = new Panel(); 
     ImageButton btnProduct = new ImageButton(); 

     btnProduct.ID = "btn" + filteredFileList[j].Name.Substring(0, filteredFileList[j].Name.LastIndexOf(".")); 
     btnProduct.ImageUrl = @"/ysyp/Images/Products/" + filteredFileList[j].Name; 
     btnProduct.Width = 50; 
     btnProduct.CommandName = "Click"; 

     Page.ClientScript.GetPostBackEventReference(btnProduct, "btnProduct_Click"); 

     btnProduct.CommandArgument = filteredFileList[j].Name; 
     btnProduct.Click += new ImageClickEventHandler(btnProduct_Click); 

     panel.Controls.Add(btnProduct); 

     trImageRow.Cells.Add(tdImageRow); 
     tdImageRow.Controls.Add(panel); 
    } 
} 

tbProductImage.Rows.Add(trImageRow); 
tdProduct.Controls.Add(tbProductImage); 
関連する問題