locked
TextBox text returns a null or “” value in the Code-behind when using a JavaScript callback function RRS feed

  • Question

  • User31042569 posted

    I have an assignment to create an ASP.NET base simple calculator with:

    3 – Textboxes: FirstNumber, SecondNumber, Results

    4 – Buttons: Plus, Minus, Multiply, Divide

    We are to use a JavaScript callback to return the results when one of the buttons are clicked.

    The issue I am having is that the values of the FirstNumber.text and SecondNumber.text are coming up as “” in the GetCallbackResult function within the code-behind. I do not know what it is I am missing. Code to follow soon.

    Wednesday, September 10, 2014 11:18 AM

Answers

  • User-760709272 posted

    Server-side controls are only available as part of a postback, they are not available through ajax calls, page methods etc.  You'll need to update your client controls using traditional ajax (ie update them through javascript rather than setting their values in your code behind).  Or you can use an updatepanel rather than writing your own ajax code.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 10, 2014 11:24 AM