簡體   English   中英

asp圖像按鈕刷新頁面

[英]asp image button refreshes page

嗨我的網頁有很多imageButtons,點擊后刷新頁面。 我該如何防止這種情況?

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

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

但是如果你想使用<asp:ImageButton>然后更新以下行來停止頁面被回發(刷新)...

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM