How to make jquery ajax call on custom control

I have an 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?


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.



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:

An example of this in UserControl can be found at:



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 !!!



All Articles