Click to See Complete Forum and Search --> : [RESOLVED] how do I kill the click event.


Bill Crawley
May 20th, 2009, 04:37 AM
Hi All,

I have some code that was working fine. The users as usual have changed the spec and now want some upfront validation on the client such that an alert appears telling the user that they haven't made a full selection instead of defaulting as per the spec.

My working code is:

<asp:UpdatePanel id="upnlButtons" runat="server" UpdateMode="always">
<ContentTemplate>
<asp:Button ID="btnOk" runat="server" Text="OK" Width="60px" OnClick="btnOk_Click" OnClientClick="javascript: window.moveTo(200,0); window.resizeTo(1000,1100);" TabIndex="4"/>&nbsp;&nbsp;
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="javascript:window.close()" TabIndex="5" />
</ContentTemplate>
</asp:UpdatePanel>

I have attempted to put a function in the Markup that returns false and change the onClientClick event to the following:

OnClientClick="javascript:if (checkme()== true) { window.moveTo(200,0); window.resizeTo(1000,1100);}"

this seems to be ok, but the OnClick server event still gets triggered when checkme returns false. I guess part is because I have the update panels updatemode set to always and this needs to be conditional.

Can anyone give me an example of what I need to do to stop the server side firing when false is returned from my client side function.

Alsvha
May 20th, 2009, 04:42 AM
Try to manually add a return false to the end of your click event, so you're sure it'll always return false.

OnClientClick="javascript:if (checkme()== true) { window.moveTo(200,0); window.resizeTo(1000,1100);return false;}"

Bill Crawley
May 20th, 2009, 06:22 AM
Thanks, that seems to have done it.

Alsvha
May 20th, 2009, 07:52 AM
I meant for the return false to be outside the if-check, so after the } would properly be best, so it'll return false even if "checkme" isn't true.