views:

1984

answers:

2

I would like to utilize the ASP.NET AJAX Page Methods functionality with a user control. Is there a way to be able to specify my static [WebMethod] inside the UserControl's code behind instead of the Page's code behind?

+3  A: 

You probably can't. The user control doesn't have all the functionality of a page and can't be called directly. You should instead create a webservice (asmx) to handle this scenario. If you wanted, the webservice call could be routed to the static method inside your user control.

Keltex
+1  A: 

I've been searching around quite a bit to find some solution to placing static WebMethods in controls. In lieu of finding a solution I had to make my own; if you're interested in being able to do this more naturally, feel free to take a look here (or skip straight to the source ). There's little documentation since the solution is fresh, but at the moment I'm the only person with interest in it so there's little reason for me to get all gung-ho on it. If you get a chance and you're interested please tell me what you think.

TheXenocide