2010年11月6日 星期六

Stop ImageButton Postback

JS 中配上這個"終結令"

function foo(event)
{
   // 第一行就堵起來
   if (window.event)
       window.event.returnValue = false;   // IE, Chrome
   else
       event.preventDefault();   // FF
   ...
 
}

在 aps.net

<asp:ImageButton runat="server" id="image" OnClientClick="foo(event)">
包准 Button, ImageButton 不會往後端送 Postback
煞車煞的住!

沒有留言:

張貼留言