Search code examples
asp.netjquery-uibuttononclickonclientclick

Jquery UI Button Server + Client Click Handlers


I am trying to write a simple HTML form using asp.net and Jquery UI but am running into a problem when trying to process click event handlers on a button within this form. I was tryign to use OnClientClick and OnClick but once the clientside method gets accessed and returns the boolean the server side method is not called accordingly( not called at all actually) Linky to code since I could not get the code tags to work properly: http://pastebin.com/LZNMqASt


Solution

  • For some reason the return type of the javascript method was not being accepted as a valid boolean. The below solution fixes the OnClientClick event

    <asp:Button runat="server" ID="btnLogin" Text="Login" OnClick="btnLogin_OnClick"
                        OnClientClick="if(ValidateLoginForm() != true) return(false);" UseSubmitBehavior="False" />