Sunday, August 22, 2010

How to stop a button being postback to server

Attach an OnClientClick java script function with return inline. From the function return false based on your logic
<%@ Page Language="C#" %>
<head id="Head1" runat="server">
    <script type="text/javascript">
        function Validate() {
            alert("Validate Controls");
            var isValid = false;
            if (isValid)
            return false;
    <form id="form1" runat="server">
        <asp:Button runat="server" ID="btnLogin" 
            OnClientClick="javascript:return Validate()" 
            Text="Login" />

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...