Saturday, March 24, 2012

Upgrading Extender control from Atlas to ASP.NET AJAX

Hi,

I have an extender control written in atlas. I want to upgrade it to asp.net ajax.

Its so sad that there are no documentation for upgrading an extender control.

My extender control is as follows.

publicclassMyExtender : ExtenderControl<MyTargetProperties>

{

public MyExtender()

{

}

publicstring ControlID

{

get

{

return (string)ViewState["ControlID"] ??"";

}

set

{

ViewState["ControlID"] =value;

}

}

protectedoverridevoid OnInit(EventArgs e)

{

// Init code

base.OnInit(e);

}

protectedoverridevoid OnLoad(EventArgs e)

{

base.OnLoad(e);

}

protectedoverridevoid OnPreRender(EventArgs e)

{

base.OnPreRender(e);

}

protectedoverridevoid RenderScript(Microsoft.Web.Script.ScriptTextWriter writer,Control targetControl)

{

// write the script here

}

}

publicclassMyTargetProperties : TargetControlProperties

{

protectedoverridebool IsEmpty

{

get {returnfalse; }

}

}

Can somebody suggest what I need to do ?

The moment I remove the Microsoft.Web.UI namespace, I get plenty of errors.

Thanks

Hi,

Maybe it's not too hard to start with a new control based on the doc, and migrate your code:

Adding Client Behaviors to Web Server Controls by Using ASP.NET AJAX Extensions

or

Adding Client Capabilities to a Web Server Control by Using ASP.NET AJAX Extensions


hello.

well, several things have change since then but i'll try to recall what yoyu need to do. the first thing is to drop the targetcontrolproperties since they are no longer needed.

the second thing you need to know is that the client behavior object (JS) is introduced in the page through what is know as a ScriptDescriptor object. currently,you have 2 options: ScriptBehaviorDescriptor and ScriptControlDescriptor (it all depends on what you're developing: behaviors or client controls). Besides one of these objects, you'll also need a scriptreference to indicate the client files that must be loaded. what you can't forget is to:

1. during prerender, call registerextendercontrol method

2. during the render method, you must call the registersccriptdescriptors

do notice that if you're extending the extendercontrol class then you don't need to worry about this: just override the abstract getscriptdescriptors and getscriptreferences methods

i still think that the easiest way to understand what's going on is to use reflector and take a look the code you have in the current version of the platform...

No comments:

Post a Comment