dynamic forms

  • Thread starter Thread starter steven scaife
  • Start date Start date
S

steven scaife

Hello, I am in need of some guidance

I am creating an app where I can create forms through a wizard. these forms
are then saved to the database and i have a class that builds the forms I
have generic handlers for some controls such as a fileupload or picture file
upload. So when the form is constructed I attach the event handler to these
controls.

Basically this allows me to create forms quickly and easily and there is no
problem if the form just saves to a database. However I want to put business
logic in a dll for each project I create. for instance when the form is saved
I may have to run some specific logic or I may have a hyperlink that when
clicked adds another textbox to the form e.g. adding extra textboxes for
names in a event registration form.

My issue is I am not sure of the best way to go about doing this.

What i am thinking is that when the form is created I have another step in
my wizard that allows me to view the methods in the dll via reflection and
save the method name and assembly name to the database. Then when the form is
created I can then use reflection to add the method to the controls event.

Is this the best way to go about doing this, should I create a set of
interfaces that the classes must inherit from for doing specific things, is
there a better way of doing what I want to do.

Colde samples are appreciated if applicable but I would prefer links to some
good resources and advice
 
Hi...

I don't have any advice but any more details and full examples on how you
did your dynamic forms wizard would be helpful. I have a very large project
coming up soon and it requires quite a bit of these dynamic forms. To add on
top of it, When the forms are created through the wizard, they have to be
redisplayed in a wizard later with logic attached to it. After the wizard is
filled out (the form) the contents of the form have to be mixed with other
text to create a complete document at the end. Any ideas how to get started?
 
Hi Andy

I have a sql backend that holds the field information. I have an object
table in a 1 to many with the fields table which is in a 1 to many with the
required fields table. there are joining tables in there to resolve the many
to many relationships but basically that is my data store.

The forms allow you to enter the cssclass for the label and the form element
i.e. textbox. as I wanted to allow a good customization of the form. I have
about 10 fields on the form as I store the sqldbtype of the field the length
etc, this is a user control and I keep track of how many of these are added
with a session variable.

when the form is created I create the controls in the page_init event and
depending on the type of control I use the info gathered and a the control to
a placeholder.

Remember that in the wizard and the dynamic form you need to recreate the
controls in either page load or page_init (both ways work for me) to maintain
the viewstate.

i would post code but the wizard is using ajax to reduce the amount of
postbacks so the code is quite convoluted. However I have included some
psuedo code

class object
'properties to hold details about the object
list of(fields)
end class

class fields
'properties holding info on field
list of (requiredfield)
end class

class requiredfield
'properties holding info on required field
end class

You can then loop through all the fields in an object and all the required
fields for a fields object

for each
select case fieldtype
case textbox
'logic to create textbox and add any required fields
case dropdownlist
'logic to create drop down and add required fields
end select
next

Basically thats about all i have i am learning as I go along, bought a book
on reflection
http://www.amazon.co.uk/Visual-Basi...=sr_1_5?ie=UTF8&s=books&qid=1234181100&sr=8-5
it's got some good examples and is well worth a read I think. even if I fail
with this project it was good for practicing delegates and events and I am
definitely a better programmer for it. i have been on several MS training
courses and never found the examples for delegates and events useful or
explanatory but I have a better understanding now.

with regards to adding events I think it will have to be a treeview control
in another page of the wizard with the methods of a class and you select the
method and save the signature to the db. Then when the page is loaded the
events can be added. Only way I can think of is via reflection

Sorry if I rattled on but hopefully there is something to get you started if
not email me at steven dot scaife @ breedcreative dot com and I'll try and
help you more
 
Hi Andy

just typed a massive reply and the system errored, maybe my session timed
out, maybe because i included a link to a book on amazon I will try and reply
again later
 
Back
Top