views:

77

answers:

1

Hi !

I just want to add some client side (JQuery Javascript) validation in a web user control. I put an OnClientClick handler and the function gets called. BUT, even if I return "false", the OnClick method always get fired. What am I doing wrong ?

I'm with VS 2010, targeting the 4.0 framework with JQuery 1.4.2. and JQuery UI 1.8.4.

Here's a sample code :

<td style="text-align:right"><asp:Button ID="btnAddSave" OnClientClick="return ValidateMail();" OnClick="btnAddSave_Click" runat="server" Text="Submit" /></td>

Script method :

function ValidateMail() {
alert("Bouton clicked");
return false;

}

If I put a breakpoint in the Page_Load event, I see that I get in and the btnAddSave_Click event is also executed.

A: 

When you view the rendered source of the HTML page, is your "onclick" event rendered in the tag or are you overwriting that in the code behind? Also, do you have any other JQuery events that bind to this control which might be intercepting the call?

Steven Raines