RaiseCallbackEvent Server Controls Such as TextBox1.Text value remains empty

Discussion in 'ASP .Net' started by emailseshu, Feb 3, 2007.

  1. emailseshu

    emailseshu Guest


    Iam trying to check the Client Side CallBack Feature in ASP.NET

    Iam able to call th RaiseCallbackEvent from the Client Side Javascript
    Function but when I go to the debug mode to check the Value of the
    TextBox it always remains "" or empty rather than the value I gave as
    input into the text box before invoking the RaiseCallBack.

    Code is simple

    1 WebForm.aspx Page

    <%@ Page Language="C#" AutoEventWireup="true" %>
    <%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <title>Untitled Page</title>
    <script type="text/javascript">
    function LookUpStock()
    var lb = document.getElementById("ListBox1");
    var product = "";//lb.options[lb.selectedIndex].text;
    CallServer(product, "");

    function ReceiveServerData(rValue)
    document.getElementById("ResultsSpan").innerHTML = rValue;


    <script runat="server">
    protected System.Collections.Specialized.ListDictionary
    protected String returnValue;

    void Page_Load(object sender, EventArgs e)
    if (!Page.IsPostBack)
    String cbReference =
    textbox1.Text, "ReceiveServerData", "context");
    String callbackScript;
    callbackScript = "function CallServer(arg, context)" +
    "{ " + cbReference + ";}";

    "CallServer", callbackScript, true);


    public string GetCallbackResult()
    bool btest = Page.IsCallback;
    return textbox1.Text; // This always comes as empty in
    debug mode why?????

    public void RaiseCallbackEvent(String eventArgument)

    // if (catalog[eventArgument] == null)
    // {
    ////////// returnValue = "-1";
    // else

    returnValue = textbox1.Text; //



    <form id="form1" runat="server">
    <asp:ListBox ID="ListBox1" Runat="server"></asp:ListBox>
    <br />
    <br />
    <button type="Button" onclick="LookUpStock()">Look Up Stock</
    <br />
    <br />
    Items in stock: <span id="ResultsSpan" runat="server"></span>
    <br />
    <br />
    <asp:TextBox ID="textbox1" runat="server"></asp:TextBox>
    <br />


    Thanks in Advance
    emailseshu, Feb 3, 2007
    1. Advertisements

  2. emailseshu

    Guest Guest

    I think you are not doing properly.You will find following url useful for
    In this in GetCallbackEventReference you have to pass value of first
    control.Then in RaiseCallbackEvent we will get value of this first
    control.Here you can write some logic by using this value of first control
    and then return string that uou want to diaplay in second control.Thereafter
    in function OnCallback(Result,Context) you have to assign the string
    returned(which you will get in result parameter) to second control through
    Hope this helps you out.
    If you find this post useful then please do click yes at "Was this post
    helpful to you".

    Thanks and Regards,
    Manish Bafna.
    MCP and MCTS.

    Guest, Feb 4, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.