2010-12-02 44 views
0

我有用戶使用圖像按鈕動態地進入頁面。 我想獲得他的ID在jQuery或JavaScript來放大圖像,但它總是隻放大最後一個圖像,這是代碼, 在此先感謝!javascript和用戶控制幫助

function moveover() { 
    document.getElementById('<% = ImageButton1.ClientID %>').height = "360"; 
    document.getElementById('<% = ImageButton1.ClientID %>').width = "200"; 

} 
function moveback() { 
    document.getElementById('<% = ImageButton1.ClientID %>').height = "130"; 
    document.getElementById('<% = ImageButton1.ClientID %>').width = "100"; 
    } 

這是頁面

foreach (DataRow p in ds.Tables["Products"].Rows) 
    { 
     ASP.product_control_ascx prod = new ASP.product_control_ascx(); 
     Panel1.Controls.Add(prod); 
     prod.Old_price = p["Regular_price"].ToString(); 
     prod.new_price = p["Your_price"].ToString(); 
     prod.watch_pic = p["Product_imag"].ToString(); 
     prod.rr = "~/ProductPage.aspx?Select_prod=" + p["Product_id"].ToString(); ; 
    } 

即使有人有一個很好的代碼,增加圖片?

+1

更多信息會很好,顯示圖像以及它們在頁面上的顯示方式。 – Dai 2010-12-02 10:57:23

回答

1

此問題的最佳解決方案是將圖像按鈕的客戶端ID傳遞給函數,如下所示。

function moveover(imageButtonId) 
{ 
    document.getElementById(imageButtonId).height = "360"; 
    document.getElementById(imageButtonId).width = "200"; 
} 
+0

我應該在HTML中寫什麼? – mnaftal 2010-12-02 11:35:11