Asp .NET Button - OnClientClick=“return function()” vs OnClientClick=“function()”

In an user control I have a button:

<asp:Button ID="addButton" runat="server" Text="Add"  OnClientClick="return function()". 

I had written jquery code to hide a control( validationsummary) present in the page inside function().

When I wrote "return function()" it behaved as I expected and the control got hidden. While when I wrote only "function"()" the control got hidden but reappeared. What exactly is the difference between the two?



First : the client side runs (OnClientClick)

Then - the server side.


The client side code can prevent execution of server side by return true/false.

usually we use it for validation , before submitting to server.

Do this and your server side will ( without hacking) never work :

OnClientClick="return false;"


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.