简体   繁体   中英

Dynamic Controls in ASP.NET Issue

I'm doing dynamic controls in asp.net and came to the point that i can go nowhere. I'm doing a page for 201 file of employees and i want that page become dynamic and controls will be coming from the database. there is a separate system for building the controls and setting up its attribute. anyone here can give me some advice how to do it, what is the database structure and what are the things to be consider. TIA.

Guys, this is the current design of my dynamic controls database:

Table Name : UM_WebObjectCategories
Columns:
    WebObjectCategoryID bigint
    ParentID bigint
    IsParent bit
    WebObjectCategory varchar

Table Name : UM_WebObjectHRIS201FileAccess
Columns:
    WebObjectHRIS201FileAccessID bigint
    HRIS201FileAccessID bigint
    WebObjectID bigint

Table Name : UM_WebObjectObjectsProperties
Columns :
    WebObjectObjectsPropertiesID bigint
    WebObjectID bigint
    WebObjectPropertyID bigint
    StringValue varchar
    BooleanValue bit
    IntValue int
    LongValue bigint

Table Name : UM_WebObjectProperties
Columns :
    WebObjectPropertyID bigint
    WebObjectProperty varchar
    ValueType varchar

Table Name : UM_WebObjects
Columns :
    WebObjectID bigint
    WebObjectName varchar
    WebObjectTypeID bigint
    WebObjectCategoryID bigint

Table Name : UM_WebObjectTypes
Columns : 
    WebObjectTypeID bigint
    WebObjectType varchar

Table Name : UM_HRIS201Access
Columns :
    HRIS201AccessID bigint
    HRIS201Access varchar

Hope you can help me to decide on this. Thanks.

I know this is old, but I have built just such a set of "dynamic controls" that can be generated from a database. Hopefully this helps anyone who comes across this post in the future. These controls use .NET's Provider model, and so will accept anything as a data source.

https://github.com/tenshino/RainstormStudios/tree/master/RainstormStudios.Web/UI/WebControls/DynamicForms

The base provider classes are part of the same repo, and can be found here:

https://github.com/tenshino/RainstormStudios/blob/master/RainstormStudios.Web/Providers/DynamicFormProvider.cs

I have done something similar for my company. Like devcoder mentioned, you really should find a senior programmer. If you do not know where to start, there is a good chance you will run into a lot of issues.

Here are some tips, just in case you/or anyone else needs to create a similar system.

  • database
    • table to hold the layout of the page
    • table to hold the questions for the page
    • look-up table to hold the type of questions
    • table(s) to store the answers
  • web side
    • map the type of question to a specific control (user controls work too)
    • if you use user controls, then make sure you register them on the page first
    • the dynamic controls will need to be re-created every post-back
    • create them on the init state so that they will work with view state (this rule can only be broken if you do not post-back at all or you use AJAX or you have your own load/save viewstate schema)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM