locked
Mcv4 with Razor Dynamic form creation RRS feed

  • Question

  • Anyone please help me to create the dynamic form using MVC4 razor and sql server as per the Admin.
    Means for each project Admin will create the form like control (textbox,dropdown,label etc) and all set the layout and alignments for the same so that when normal user open as per his rights to the project he/she will see the form which have been configured for him.

    I have made the enum like   public enum dataFieldType
        {
            TextBox = 0,
            TextArea = 1,
            DropDown = 2,
            CheckBox = 3,
            Label = 4
        }
    and database fields like 
    CREATE TABLE [dbo].[pr_tblFields](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [pid] [int] NULL,
    [Name] [nvarchar](250) NULL,
    [Type] [nvarchar](50) NULL,
    [Required] [bit] NULL,
    [choices] [nvarchar](max) NULL,
    [ordinal] [int] NULL,
    [Datecreated] [datetime] NULL,
    [Datemodified] [datetime] NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    i don't know how to go through.Urgent for my projec
    • Moved by Mike Danes Friday, May 22, 2015 7:01 AM asp.net related
    Friday, May 22, 2015 5:10 AM

Answers

All replies

  • Please use the ASP.NET forums for ASP.NET related questions: http://forums.asp.net/

    • Proposed as answer by Just Karl Friday, May 22, 2015 7:44 PM
    • Marked as answer by Just Karl Tuesday, June 2, 2015 10:26 PM
    Friday, May 22, 2015 6:27 AM
  • This is not as easy as webform because the View is render by the Controller. You have a model but you need Controller and View to be generated.

    chanmm


    chanmm

    Friday, May 22, 2015 7:00 AM
  • So how i can do that if you know please help me this is my urgnet requirement.I made a model

     public abstract class ControlViewModel
        {
            public abstract string Type { get; }
            public bool Visible { get; set; }
            public string Label { get; set; }
            public string Name { get; set; }
        }
        public class TextBoxViewModel : ControlViewModel
        {
            public override string Type
            {
                get { return "textbox"; }
            }
            public string Value { get; set; }
        }
        public class CheckBoxViewModel : ControlViewModel
        {
            public override string Type
            {
                get { return "checkbox"; }
            }
            public bool Value { get; set; }
        }
        public class DropDownListViewModel : TextBoxViewModel
        {
            public override string Type
            {
                get { return "ddl"; }
            }
            public SelectList Values { get; set; }
        }
       

    but how can i do it


    SujitAAtish

    Wednesday, May 27, 2015 4:19 AM