How to make jquery ajax call on asp.net custom control

I have an asp.net custom control on which I want to use jquery ajax. It is basically a popup form that allows users to enter a name in automatic full control. I don't know how to do this using jquery ajax because in the jQuery ajax call I have to specify the page name in the url: section and then the method to call. However, I want to put this method in the .cs file of the custom control. Is there a way to do this, or do I need to create a page to hold the ajax methods?

+2


source to share


3 answers


The custom control is different from the page, so you cannot call it from your jquery. If you are using Asp.Net AJAX you can put method in page method. Otherwise, you must put it in a webservice.



+2


source


ICallbackEventHandler is the best option if you don't want to use webservice. It internally makes the ajax call.

Details on ICallbackEventHandler can be found at:

http://msdn.microsoft.com/en-us/library/system.web.ui.icallbackeventhandler.aspx



An example of this in UserControl can be found at:

http://www.codeproject.com/Articles/27172/The-ICallbackEventHandler

+1


source


Be careful with the "Ajax Request Call" in the custom control for other resources (in this case, web services). If you are calling a service from your control to an external application (different domain), you are probably facing a "Cross Domain Ajax" Request !!!

0


source







All Articles