Reputation: 245
I have an ImageButton as follows
<asp:ImageButton OnClientClick="javascript:merge();" ID="MenuLinkMerge" Text="Merge" ToolTip="Merge" SkinID="Merge32" runat="server" onclick="MenuLinkMerge_Click" />
merge() will call
function merge() {
if (IDList.length > 0) {
alert("go");
return true;
} else {
alert("No companies were selected.");
return false;
}
}
but whether I return true or false the MenuLinkMerge_Click is always called server side and the page is redirected. I only want the page to change if IDList.length > 0 otherwise display the alert and do nothing.
How do I accomplish this?
Upvotes: 1
Views: 582
Reputation: 3604
Change your onclientclick handler to this -> OnClientClick="return merge();"
Upvotes: 3