views:

20

answers:

1

I want to put context-sensitive, dynamic command options on my asp.net pages.

I tried coding my own command structure but it's not very good, and I'm sure there must be a framework for doing this somewhere I can re-use?

Example: I have a detailsview for some database object, I want to code in the object class what commands are available, based on the state of the object. I then want a UI object I can place on the webform that will pass commands back to the object when user clicks them, or jump to a different link (e.g. when additional parameters are available).

e.g. form might look like this


Product Details

Name: XXXX product
Price: $1.00
Qty: 1

Commands:

> Edit
> New Stock
> Mark as obsolete


So the commands at the bottom would have very little UI code and pass actions back to the object. For example the New Stock command would jump to a new page to ask for a quantity.

+1  A: 

I don't know of the framework, but you could create something yourself. Let's say you are using MVP pattern, and assuming that this is a CRUD application, you could tell each view what type of object it is related to, then annotate you object with operations that are available. Then Presenter could call Service to perform the operation. You could name your methods using some convention so that you can wire it up in a Service. It is a lot of work, and unless you have 100s of views it is not worth while. I am building app that is about that size, and I am in process of creating GenericMVP framework, that would make wiring a breeze.

epitka
Thanks for the suggestions. Seems like a common application behaviour and yet I guess everyone must manually create buttons and/or links in the UI to do it.
Quango
Figured out that actually the ASP.NET menu is the easiest way to generate a command list. In VS2010 it can be configured to generate ul and li elements and then use styles to format. The commands can generate Command events and these can be handled by subclassing the menu.
Quango