Showing posts with label behaviors. Show all posts
Showing posts with label behaviors. 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.

Wednesday, March 21, 2012

Event handlers for behaviors using the extenders

Hi

Is there a way to set the handler for an event of a behaviour (i.e. expandedCompleted for CollapsiblePanel) using the extender and the extender properties?
In this case, the behavior has the event, but in the CollapsiblePanelProperties only the properties are available.

Thank you
Vlad

Unfortunately, this doesn't work because the events on the behavior are client side, and any event hookups done via the ASPX are server-side.

To hook up to those events, you'll need to it from Javascript, which is possible. I think you can set an ID property in your properties declaration and then access that object at runtime with "$object('idValue')". Once you have that, you can hook up to the event, but again, it's in script at runtime.


My understanding is that the extenders act as a helpers or wrappers for the atlas behaviors so that they can be used easier from Visual Studio(please correct me if i'm wrong). This means that the properties from the CollapsiblePanelProperties are passed to the CollapsiblePanelBehaviour.
Wouldn't it be possible then to pass the name of the event handler as a text property? Of course the event handler would have to be a javascript function, but the assignment could be done at design time, just like when the behaviors are used without the extenders, something like this:

<textBox id="myTextBox"> <behaviors> <clickBehavior click="onTextBoxClick" /> <keyPressBehavior keypress="onTextBoxKeyPress" /> </behaviors> </textBox>

Thank you,
Vlad

Yes you're right - I misread your question.

This is a good idea - thanks for bringing it up. One thing we're kind of sturggling with is how much to blur the client and server models. We've already crossed this line in a few places (very similar to what you propose actually) and I need to do more thinking about what the pattern is here. So you've "planted the seed", let me think more about this, what the semantics are, etc.

Shawn