I don’t think the question is clear here.
Simply I have 19 types of items in my system. and I have 19 pages each one allow me to add a new item of specific type.
The “Add New Item” page and the “Edit an existing Item” page, are very similar from each other .. all what I need is to hide/show a couple of controls.
so I thought I’d use QueryString to define how we’ll be using the page, if new then everything will remain the same and if it’s used for “editing” then I’ll change the Text properties for a couple of labels and show some extra TextBoxes and DropDownLists.
I could do this in a several ways but it will be a mess. I was hoping that someone could propose a way to do this keeping in my a good design and architecture.
Thanks for your time =)
1- Declare an InstanceState property for the page or the type. Make it read and write its value to a ViewState variable if it is for the page.
2- Use an enumuration to declare the possible values of this property. You can declare numerous of values to this property like (New, OnEdit, OnRead ).
3- Declare some other boolean properties to help you in customising your layout easily like (InstanceIsNew, InstanceIsOnRead, InstanceIsOnEdit ..). Those properties depend on the InstanceState property to return their values.
4- Bind your layout items to those properties to show, enable and what ever else you need to do on your layout items according to their values.
5- Change the value of the InstanceState on the appropriate events to change your layout.
NOTE: You might find it a bit complicated when you work on it for the first page. But once you understand the logic of it you can apply it easy and fast on the others.