开发者

Creating a framework for ASP.NET web forms similar to Flex states

开发者 https://www.devze.com 2022-12-27 06:05 出处:网络
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:

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?


The States paradigm is a good one, and exists in similar fashion in WPF applications. The important difference between ASP.NET and Flash/Flex is that ASP.NET is an HTTP-based framework.

I can envision a javascript-based framework that could mimic a states-based page, but it might have limited application because you wouldn't want to pack too much UI into a single web page. That would be a real bandwidth hog and would be even worse separation of concerns.

If it's separation of concerns you're looking for, ASP.NET MVC might be worth looking into.

0

精彩评论

暂无评论...
验证码 换一张
取 消