简体   繁体   中英

Button OnClick not fire after OnClientClick

I know many posts discussed about it. but I still can't find any solution works.

my ASPX CODE

<asp:Button ID="Booking1Btn" runat="server" CssClass="col-8 SureButton" Text ="NEXT" OnClientClick="javascript: return calcRoute()" OnClick="Booking1Btn_Click" />

if calcRoute() all route return false. the calcRoute() working fine, but onClick not fire. if calcRoute() return true, OnClick fire. but calcRoute() not working.

I have try OnClientClick="if (!calcRoute()) { return false; }" and OnClientClick="calcRoute(); return false; ". but all same, after onClientClick, onClick not fire.

why this rule not working,

calcRoute return true, onClick fired, 
calcRoute return false, onClick not fired. 

Try this code. It might possible that OnClientClick you have to mention onclick function and initialise return value.

<asp:Button ID="Booking1Btn" runat="server" CssClass="col-8 SureButton" Text ="NEXT" OnClientClick="javascript: calcRoute(); return false" OnClick="Booking1Btn_Click" />

function calcRoute(){
return true;
}

尝试这个。

<asp:Button ID="Booking1Btn" runat="server" CssClass="col-8 SureButton" Text ="NEXT" OnClientClick="return calcRoute()" OnClick="Booking1Btn_Click" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM