2012-08-08 101 views
0

嗨我的網頁有很多imageButtons,點擊刷新頁面。我如何防止這種情況?asp圖像按鈕刷新頁面

var imageButton = new ImageButton(); 
    imageButton.ImageUrl = "Styles/unClicked.png"; 
    imageButton.ID = "btn" + questionName; 
    imageButton.OnClientClick = ("javascript:button_pressed()"); 

回答

2

我的第一個答案是,如果您不希望圖像後回,不使用<asp:ImageButton>,只是使用<img>元素。

但是,如果你想使用<asp:ImageButton>然後更新以下行停止網頁張貼回(刷新)...

imageButton.OnClientClick = "button_pressed();return false;" 

注意,你不需要初始「的javascript: 「(瀏覽器知道這是javascript)

+0

現貨上,歡呼聲 – geminiCoder 2012-08-08 09:47:47

+0

不客氣@gemini,祝你好運,其餘的項目:-) – freefaller 2012-08-08 09:52:07