Search code examples
jquerywebformsservercontrols

Call Asp.Net webforms server control method using jQuery .ajax method


I'm trying to create a web forms server control and really wanted to leverage jQuery to handle the client side interaction.

So far I've not found any examples to being able to directly call a server control using the jQuery .ajax functionality and I'm wondering is it even possible?

I know I could go down the web service or Http Handler route but my aim is to create a control that can be dropped into existing sites and utilise session but with no intention of needing to use ViewState.

Can this be done? or do I have to use the ScriptControl and Asp.Net Ajax functionality?


Solution

  • Unfortunately, no.

    Probably the closest is to create an HttpHandler class and include it in your server control's DLL. Then, you'll only need a single line added to your web.config to wire the handler class up to an endpoint that jQuery can communicate with.