Onclient and OnClientClickt events not working friendly...help needed...thanks

Howdy folks,

I tried whole day…but couldn’t figure this out.

There is a <asp> button control. When it is clicked, I have two handlers on it. One is client side and other is server side.

I want the client side (javascript) to be fired before the server side code is fired. So I made the client side javascript code to return false on a conditional statement and return true if the condition is successfull. From my samples, I learnt that if the javascript funtion returns false the server side code doesn’t get fired. But, for some reason, it doesn’t behave like that. So I had to use UseSubmitBehaviour='false" on the button control. This way, the server side event is not getting fired. But I want the server side event to get fired when the client side script returns false. How can i do this? I tired whole day…any help is greatly appreciated.

<%@ Page Title="" Language="C#" MasterPageFile="~/QRMDMS.Master" trace="true" AutoEventWireup="true" CodeBehind="WebForm7.aspx.cs" Inherits="FHLBSF.QRMDMS.WebUI.WebForm7" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

<div style="height: 25px">

</div>

<div style="table-layout: fixed; width: 600px; height: 65px; position: fixed; z-index: auto;">

    <fieldset style="width: 382px; height: 47px;">
        <legend style="font-weight: bold">BS-IS Types</legend>
        <asp:DropDownList ID="DropDownListBSISTypes" AutoPostBack="false" runat="server"
            Height="23px" Width="362px">

         </asp:DropDownList>

    </fieldset>

    <asp:Button ID="ButtonAdd" UseSubmitBehavior="true" OnClick="ButtonAddClick" OnClientClick="return AddClientSide();" Text="Add" runat="server" />
    <asp:Button ID="ButtonEdit" runat="server" Text="Button" />
    <asp:Button ID="ButtonRemove" runat="server" Text="Remove" />

 <div>
        <asp:Label ID="LabelBSISType" runat="server" Text="BS-IS Type"></asp:Label>
        <asp:TextBox ID="TextBoxBSISType" runat="server" Width="282px"></asp:TextBox>
    </div>

  <script  type="text/javascript">
      function AddClientSide() {

          alert("started the client side script");

          var varButtonAdd = document.getElementById("<%=ButtonAdd.ClientID%>");

          var varproperty = varButtonAdd.getAttribute("value");

          if (varproperty == "Save") {
              alert("button now is in save mode");

              varButtonAdd.setAttribute("value", "Add");
              return false;
          }
          else {
              alert("button now is in add mode");
              varButtonAdd.setAttribute("value", "Save");
             return true;
          }      }

</script>
</asp:Content>
protected void ButtonAddClick(object sender, EventArgs e)
        {

            Loggers.AssemblyLogger.Debug("Button Add click");

            try
            {
                string a = "";
            }
            catch (Exception ex)
            {
                Loggers.AssemblyLogger.Error(ex);
                throw;
            }


        }

This might probably work, i havent tested though:

OnClientClick=“return !AddClientSide();”

what does “!” mean in Javascript if you put it before a function?