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

No comments:

Post a Comment