I have an asp.net user control on which I want to use jquery ajax. It's basically a pop-up form which allows users to enter a name on an auto-complete control. I don't know how to make this happen using jquery ajax, because in the ajax jquery call i'm supposed to put in a page name in the url: section, and then the method to call. However, I want to put the method in the .cs file of the user control. Is there a way to make it happen, or do I have to create a page just to hold the ajax methods?
3 Answers
A user control is different from a page, so you can't call it from your jquery. If you're using Asp.Net AJAX you can put the method in a page method. Otherwise you should put it in a webservice.
1 Comment
ICallbackEventHandler is the better option if you do not want to use webservice. It internally makes an ajax call.
Detail about ICallbackEventHandler can be found at:
http://msdn.microsoft.com/en-us/library/system.web.ui.icallbackeventhandler.aspx
The example of it, in UserControl, can be found at:
http://www.codeproject.com/Articles/27172/The-ICallbackEventHandler