Creating a framework for ASP.NET web forms similar to Flex states.
Posted
by Shawn Simon
on Stack Overflow
See other posts from Stack Overflow
or by Shawn Simon
Published on 2010-04-13T16:22:46Z
Indexed on
2010/04/13
16:33 UTC
Read the original article
Hit count: 368
I really enjoy the flex states framework. You define a few states for your control, and then can set child controls to only appear in certain states. Check out this code:
<s:states>
<s:State name="signin"/>
<s:State name="register"/>
</s:states>
<mx:FormItem label="Last name:" includeIn="register" id="lastNameItem" alpha="0.0">
<s:TextInput id="lastName" width="220"/>
</mx:FormItem>
Now the last name form will only appear in the register screen. This would be really useful I think in .NET where you use the page for views like update / insert. I was considering extending the Page element to have a states property using extension methods, and adding the include in to controls. This way I could auto-hide controls based on the current view at render time.
What is even cooler in Flex, is that you can use different handlers / properties based on the current state.
<s:Button label="Sign in" label.register="Register" id="loginButton"
enabled="true" click.signin="signin()" click.register="register()"/>
I'm sure there's a way I could implement something similar to this as well.
Do you think this is a good idea? Or does it just add a level of abstraction to framework that already has a poor separation of concerns?
© Stack Overflow or respective owner