Friday, January 30, 2009

How To Stop Ajax Post Back when A button contains OnClick() and onclientclick events

When A button Contains Two event functions ,one on client side and the other on Server side, The Page posts back event occurs even when the page doesn't pass the validation.
To Avoid this unwanted post back ,we should explicitly call the method
Page_ClientValidate() in the javascript event method or function.
Here is the Example:
< asp:ImageButton ID=”imgBtnSubmit” CssClass=”image” ValidationGroup=”Submit” onclientclick=”javascript:if(Page_ClientValidate())return HaspopUpClosed(); “ OnClick=”imgBtnSubmit_Clicked” runat=”server” ImageUrl=”~/res/images/img/Updatebtn.jpg” />

No comments: