Hi!
I am working on a composite control in which I add a ScriptManager programmatically. I also have a static method exposed as [WebMethod] inside the Composite Control. I have set the script manager's EnablePageMethods=true.
I added this control to a web page, but when I run the page, it seems that the Web Method client-side scripts are not being generated. Is there a way to make this work?
Thank you!
Not directly, no. pagemethods are only available as a collection when they're written in the codefile; I'm not sure of the reasoning behind this. You have three options for composite controls aside from using UpdatePanels:
1) expose properties to let the page developer specify a web service / service method.
2) expose a property to let the page developer specify a pagemethod (this could be combined w/ #1 to let the dev. use either one)
3) use Sys.Net.WebRequest calls to the containing page, and mimic the post data that would go on a full postback. Optionally, add a custom header that tellsyour control that it's an ajax call so that you can respond with only the data instead of the whole page markup.
No comments:
Post a Comment