It seems to me that I have done this script many times, and it usually works, so I clearly do not see anything.
Here is my ASP.NET server button:
<asp:Button ID="btnFoo" runat="server" Text="Foo" CssClass="button foo" OnClientClick="foo_Click();" />
Which will be displayed on the client as:
<input type="submit" name="reallylongclientid" value="Foo" onclick="foo_Click();WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(reallylongclientidandpostbackoptions, false, false))" id="reallylongclientid" class="button foo">
There are no surprises.
Here is a surprise in my JavaScript function:
function foo_Click() { return false; }
Okay, so for me it is more, but I cut it to prove the point.
When I click the button, it calls the function on the client side and returns false.
But it still goes back to the server, why?
Basically I want to do this with the click of a button:
- Client side confirmation.
- If verification passes, send a message back
- If not, show some error messages on the form.
Of course, I could change this to a client-side button (input type = "button") and manually start the postback whenever I want, but I don't need to do this. Or should I?
RPM1984
source share