Is it possible to call a method that is not tagged with [Ajax.AjaxMethod] from an AjaxMethod? Basically I have a method that populates a GridView control which is itself inside an UpdatePanel; it loads some data, sets some properties, etc. However, I need to also call this method from an AjaxMethod that will pass the same information to it that a non-Ajax method does. The problem currently is the GridView control is null when the AjaxMethod tries to call methods on it, resulting in a NullReferenceException.
How can I fix this so the Ajax method can access controls on the page? I don’t think I can simply re-instantiate the control at runtime. Should I be running the Ajax code inside of an UpdatePanel or something like that, instead of making the call directly via JavaScript? I need to do some client-side processing as a callback as well, so that’s why I was calling the AjaxMethod direct from JavaScript, but I cannot access the controls on the page which are filled by the method.
Why don’t you use Jquery’s AJAX method?