title: Execute client & server side code with one click?
body: <p>i am not sure if my design have flaw but would like to know what others have to say, i am in a situation where i am trying to acheive two things in one click.</p>
  
  <p>using : asp.net web form </p>
  
  <p>i have a web form with few textbox and a gridview control and a button.</p>
  
  <p>if i click on the button i am executing two things</p>
  
  <p>1) asynchronously get data from server to client (working great) and able to display the data in the textboxes.</p>
  
  <p>2) same click i want to bind the gridview.</p>
  
  <pre><code>&lt;asp:Content ID="Content2" ContentPlaceHolderID="cphMaster" runat="server"&gt;
       &lt;asp:Label runat="server" ID='Label1' &gt;Id:&lt;/asp:Label&gt;
  
          &lt;asp:TextBox ID="txtId" runat='server'&gt;&lt;/asp:TextBox&gt;
  
          &lt;asp:Button ID="btnSubmit" OnClientClick="LoadDataById();" runat="server" Text="Submit" 
           onclick="btnSubmit_Click" /&gt;
          &lt;br /&gt;
           &lt;br /&gt;
          &lt;asp:TextBox ID="txtName" runat='server'&gt;&lt;/asp:TextBox&gt; &lt;br /&gt;
          &lt;asp:TextBox ID="txtPurpose" runat='server'&gt;&lt;/asp:TextBox&gt;    &lt;br /&gt;
       &lt;br /&gt;
  
       &lt;asp:GridView ID="GridView1" runat="server"&gt;
       &lt;/asp:GridView&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p><strong>server side</strong></p>
  
  <pre><code>        protected void btnSubmit_Click(object sender, EventArgs e)
          {
              GridView1.DataSource = laodData(int.Parse(txtId.Text));
              GridView1.DataBind();
          }
  </code></pre>
  
  <p><strong>Jquery:</strong></p>
  
  <pre><code>function LoadVisitBasicByVisitId() {
  
  
      ContactServiceProxy.invoke({ serviceMethod: "GetDataById",
          data: { request: request },
          callback: function(response) {
  
             processCompletedContactStore(response);
          },
          error: function(xhr, errorMsg, thrown) {
              postErrorAndUnBlockUI(xhr, errorMsg, thrown);
          }
      });
      return false;
  } 
  </code></pre>
  
  <p><strong>recap:</strong></p>
  
  <pre><code>1) jquery script execute asynchronously to get data from server to client and display in the textboxes
  2) server side code to bind the gridview.
  </code></pre>
  
  <p><strong>PROBLEM:</strong></p>
  
  <p>if i have onClientClick="return LoadDataById(); then it executes ONLY ajax code and does not execute server side </p>
  
  <p>but if have onClientClick="LoadDataById(); then it executes client and server but textbox value wipeout. (the textbox value popuplate through ajax)</p>