Monday, March 26, 2012

Exposing Web Services from a custom control

In one of quickstart tutorials there is a way to use a WebMethod straight in the aspx.page(http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#webpage)

<%@dotnet.itags.org. Import Namespace="System.Web.Services" %
...

<script type="text/C#" runat="server">
[WebMethod]
public string HelloWorld(string s)
{
return "Hello '" + s + "'";
}
</script>

This example calls

PageMethods.HelloWorld(document.getElementById("nameTextBox").value, OnWebRequestComplete1);
on the client side

I am developing custom controls and am wondering if I can call a WebMethod from within my custom control.

I would imagine I have to register the namespace and class of my custom control but I don't know how. It obviously works on the aspx page because of the built-in PageMethods function

IMHO, you can't do this in the current version of Atlas because the Atlas Server Library doesn't provide this future. It will be necessary to look through control tree searching special methods... And Atlas must have an ability to know, which instance of webcontrol was called by client script. It's very difficult, as I think.

No comments:

Post a Comment