Showing posts with label tutorials. Show all posts
Showing posts with label tutorials. Show all posts

Wednesday, March 28, 2012

Extending Server Controls?

I see this blurb on the tutorials section:

"Extend server controls or control extenders: You might create new behaviors for given server controls by implementing a server control that also implements the IScriptControl to render the ASP.NET "Atlas" client script and register with the ScriptManager in the Web page. Page developers will gain from specific new server-side controls without needing to write ASP.NET "Atlas" script or JavaScript."

This is great to hear, anyone know how this works? ie. I see it says I don't need to write script at all?

Let's say I wanted a input mask textbox - how would I 'extend' the TextBox using IScriptControl and do this code without writing script?

Hi,

check alsothis article from my blog for an introduction to extenders.

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.