The Callback feature that enables you to retrieve page values and populates them to an already generated page without regenerating the page.  This capability makes it possible to change values on a page without going through the entire postback cycle.

It uses the following method: 
  • Page.ClientScript.GetCallbackEventReference()
  • Page.ClientScript.RegisterClientScriptBlock()
  • GetCallbackResult()
  • RaiseCallbackEvent()

And it inherites class is System.Web.UI.ICallbackEventHandler

How we implement the Callback


Step1: we use the following code on aspx page

 <head runat="server">
    <script type="text/javascript">  
    function ss()
    var va=document.forms[0].Text1.value;
    function amit(Text1,context)
    <form id="form1" runat="server">
      <input id="Text1" type="text" runat="server" /><br />
      <input id="Button1" type="button" value="button" onclick="ss()"/>

  Step2: We write the following code on aspx.cs page. 

 public partial class y : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler
    private string aa = null;
    protected void Page_Load(object sender, EventArgs e)
        string cref = Page.ClientScript.GetCallbackEventReference(this, "arg", "amit", "context");
        string cscript = "function UseCallback(arg,context)" +
            "{" + cref + ";" + "}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UseCallback", cscript, true);
    public string GetCallbackResult()
        return aa;
    public void RaiseCallbackEvent(string eventArgument)
        aa = eventArgument;

Step3: Run the project



  Modified On Nov-29-2017 07:25:22 PM

Leave Comment