Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 330437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:40:52+00:00 2026-05-12T09:40:52+00:00

This is the control builder class… public class ControlBuilder { /// <summary> /// Html

  • 0

This is the control builder class…

public class ControlBuilder
{
    /// <summary>
    /// Html Control class for controlbuilder Control .
    /// </summary>
    protected HTMLControl formControl;

    /// <summary>
    /// Html Control class for the label.
    /// </summary>
    private HTMLControl labelControl;


    /// <summary>
    /// Getting the property for the Control .
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    public HTMLControl Form
    {
        get { return formControl; }
    }

    /// <summary>
    /// Creating a label for the Control.
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    public HTMLControl Label
    {
        get { return labelControl; }
    }

    /// <summary>
    /// Creating a construtor for the controlbuilder taking in Zero 
    /// arguments it creates a labl for the Control .
    /// </summary>
    /// <history>
    /// [LuckyR] 13/8/2009 Created
    /// </history>
    public ControlBuilder() { }

    /// <summary>
    /// A construtor for the controlbuilder which
    /// creates a label for the Control .
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    public ControlBuilder(string labelName)
    {
        Label label = new Label();
        label.Text = labelName;
        label.Width= 200;
        labelControl = new HTMLControl(label);
    }


    /// <summary>
    /// Control build property that is used to biuld the Html 
    /// markup for the created Control.
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    public string BuildControl()
    {
        this.CreateControl();
        this.SetAttribute();
        return this.RenderHTML();
    }

    /// <summary>
    /// Render Html tags for the Control with label . 
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    public string RenderHTML()
    {
        return labelControl.RenderHTML() + ": " + formControl.RenderHTML();
    }

    /// <summary>
    /// Used to Set Attributes for the Control .
    /// </summary>
    /// <history>
    /// [LuckyR] 13/8/2009 Created
    /// </history>
    protected virtual void SetAttribute() { }

    /// <summary>
    /// Used to create the Control . 
    /// </summary>
    /// <history>
    /// [LuckyR] 13/8/2009 Created
    /// </history>
    protected virtual void CreateControl() { }

    /// <summary>
    /// A list of all the Controls that will be created during the 
    /// program run .
    /// </summary>
    private IList<ControlBuilder> Controls = new List<ControlBuilder>();

    /// <summary>
    /// A property to add Control to the ControlBuilder that are created by 
    /// the user.
    /// </summary>
    /// <history>
    /// [LuckyR] 13/8/2009 Created
    /// </history>
    /// <param name="Control">Controls from the controlbuilder class</param>
    public void AddControl(ControlBuilder Control)
    {
        Controls.Add(Control);
    }

    /// <summary>
    /// A property to display the Controls that are created by 
    /// the user.
    /// </summary>
    /// <history>
    /// [LuckyR] 13/8/2009 Created
    /// </history>
    public string Display()
    {
        string Html = string.Empty;

        foreach (ControlBuilder builder in Controls)
        {
            Html += builder.BuildControl();
            Html += "<br /><br />";
        }

        return Html;
    }
} 

}

this is how i build a control

public class TextBoxBuilder : ControlBuilder
{
    /// <summary>
    /// Creating a web Control textBox.
    /// </summary>
    private TextBox textBox;

    /// <summary>
    /// Creating an Id to add as an attribute .
    /// </summary>
    private string Id;

    /// <summary>
    /// Creating an Value to add as an attribute .
    /// </summary>
    private string Value; 

    /// <summary>
    /// Creating a Textbox constructor which takes in LabelName and Id. 
    /// to create a label for the Control. 
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    public TextBoxBuilder(string labelName, string id , string value): base(labelName)
    {
        this.Id = id;
        this.textBox = new TextBox();
        this.Value = value;
    }

    /// <summary>
    /// Used to Set properties for the Control . 
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    protected override void SetAttribute()
    {
        this.textBox.ID = this.Id;
        this.textBox.Text = this.Value;
    }

    /// <summary>
    /// Used to create the Control . That is done by calling the HtmlControl class 
    /// which inturn renders the particular Control for us .
    /// </summary>
    /// <history>
    /// [LuckyR] 10/8/2009 Created
    /// </history>
    protected override void CreateControl()
    {
        this.formControl = new HTMLControl(this.textBox);
    }
} 

}

In my home controller i did this …

      public ActionResult Create()
      {
         ///Where i am contacting the linq to sql classs for performing ths operagtion
         foreach (var control in Rep.GetData(ScreenName))
         {
            string Type = control.Type;
            string value = null;
            if (id != Guid.Empty)
            {
                value = DataObj.GetValue(control.TableName, control.ControlName, id);
            }

            switch (Type)
            {
                case ("TextBox"):
                    /// Buliding a textBox box 
                    controlbuilder.AddControl(new TextBoxBuilder(control.Field, control.ControlName, value));
                    break;

                case ("CheckBox"):
                    /// Bulidig a CheckBox .
                    controlbuilder.AddControl(new CheckBoxBuilder(control.Field, control.ControlName , value));
                    break;

                case ("DatePicker"):
                    /// Bulidig a DatePicker .
                    controlbuilder.AddControl(new DatePicker(control.Field, control.ControlName, value));
                    break;

                case ("DropDownList"):
                    ///Building a dropdownlist.
                    List<string> list = DataObj.GetDropDownValues(control.Id);
                    controlbuilder.AddControl(new DropDownListBuilder(control.Field, control.ControlName, list,value));
                    break;

                case ("TextArea"):
                    /// Building a textBox area .
                    controlbuilder.AddControl(new TextArea(control.Field, control.ControlName , value));
                    break;

                default:
                    break;
            }
        }

        return View(controlbuilder);
       }

The view page looks like this …

<% using (Html.BeginForm())
   {%>
<fieldset>
    <legend>Fields</legend>
    <p>
        <%= ViewData.Model.Display() %>
    </p>
    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>
<% } %>
<div>
    <%=Html.ActionLink("Back to List", "Index")%>
</div>

since i am passing my class into the view i can retrieve all the data there with .display .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:40:52+00:00Added an answer on May 12, 2026 at 9:40 am

    There is no concept of controls in ASP.NET MVC any longer.

    You have two options:

    1. When the user clicks a button, you handle this POST request in a controller action, set some sort of flag in your view model to now show a textbox, then return the same view which in its turn will look at the flag and generate a text box if required. This will incur a complete round-trip which will be somewhat similar to the postback in WebForms.

    2. You do it in-place with JavaScript. You intercept a click event on a button and you inject an input/textarea HTML element into your document structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

This is the control builder class... public class ControlBuilder { /// <summary> /// Html
Given that the only way to unload dynamically compiled assemblies (to reclaim memory) is
I am talking about the navigation area on the left side of iTunes for
I'm designing a simple Quiz application. The application needs to display different types of
I'm fairly new to .Net... I have several queries which will execute when the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.