title: How to handle multiple callbacks in ASP.Net 4.0 C#? Example
body: <p>I have to handle two callbacks in one page one on button event and other on List.</p>
  
  <p>When button 'showDate' is clicked it display Time
   and when button 'btnlookup' is clicked it show the respective value of listbox item.. below is my code HTML &amp; .cs file</p>
  
  <pre><code>&lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script language="javascript"&gt;
          function ReceiveResults(arg, context) 
          {
              showDate.innerHTML = arg;
          }
  
          function LookUpStock() {
              var lb = document.getElementById("ListBox1");
              var product = lb.options[lb.selectedIndex].text;
              CallServer2(product, "");
          }
  
          function ReceiveServerData(rValue) {
              document.getElementById("ResultsSpan").innerHTML = rValue;
  
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;span id="showDate"&gt;aaa&lt;/span&gt;
          &lt;/br&gt;
          &lt;input id="btnShowDate" type="button" value="getDate"  onclick="CallServer();"/&gt;
  
      &lt;/div&gt;
  
          &lt;div&gt;
        &lt;asp:ListBox ID="ListBox1" Runat="server"&gt;&lt;/asp:ListBox&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;button type="btnLookUP" onclick="LookUpStock()"&gt;Look Up Stock&lt;/button&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        Items in stock: &lt;span id="ResultsSpan" runat="server"&gt;&lt;/span&gt;
        &lt;br /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Code for .cs file</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  public partial class callback : System.Web.UI.Page, ICallbackEventHandler
  {
     protected String returnValue;
     protected String myDate;
     protected System.Collections.Specialized.ListDictionary catalog;
  
  
      public String GetCallbackResult()
      {
          //return returnValue;
          return myDate;
      }
  
      public void RaiseCallbackEvent(String eventArgument)
      {
          myDate = System.DateTime.Now.ToLongTimeString();
  
  
          //if (catalog[eventArgument] == null) 
          //{
          //    returnValue = "-1";
          //}
          //else
          //{
          //    returnValue = catalog[eventArgument].ToString();
          //}
      }
  
      protected void Page_Load(object sender, EventArgs e)
      {
          //For Time
          ClientScriptManager cSM = Page.ClientScript;
          String myCBRefrence = cSM.GetCallbackEventReference(this, "arg", "ReceiveResults", "context");
          cSM.RegisterClientScriptBlock(this.GetType(), "CallServer", "function CallServer(arg, context) {" + myCBRefrence + ";}", true);
  
          //callback back for listbox
              //String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
              //String callbackScript = "function CallServer2(arg, context){ " + cbReference + ";}";
              //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer2", callbackScript, true);
  
              //catalog = new System.Collections.Specialized.ListDictionary();
              //catalog.Add("monitor", 12);
              //catalog.Add("laptop", 10);
              //catalog.Add("keyboard", 23);
              //catalog.Add("mouse", 17);
  
              //ListBox1.DataSource = catalog;
              //ListBox1.DataTextField = "key";
              //ListBox1.DataBind();
  
      }
  }
  </code></pre>
  
  <p>Code which is comments is for the second callback event, Problem is in this code is that i can only raise one callback, can someone tell me what changes i need to make in code so that i can raise both callback event.</p>