The main purpose of this feature is to create web interface such as Create and Edit form very easily. We don't need to care much about the table layout. The FormBuilder will help you handle it if you tell it how many columns you wish to have in this form. Then it can help you calculate the width of each cell.

As we know, old web controls are abandoned in ASP.NET MVC. In order to take advantage of webcontrols in old ASP.NET version, I created a class called WebControl which is almost same as the class in System.Web.UI.WebControls namespace except the Render method is public instead of protected. This will greatly help ASP.NET MVC render such controls very easily.

I have created the following controls for the FormBuilder:
Button
CheckBox
DatePickerBox based on the datepicker in jQuery UI
Label
PopupBox
RadioBox
CheckboxList
RadioBoxList

To create a new form of Create or Edit, the code looks like below:
In Controller
private jQueryFormBuilder CreateForm()
{
jQueryFormBuilder formbuilder = new jQueryFormBuilder();
formbuilder.CssClass = "tabcontainer";
FormGroup formgroup1 = new FormGroup("BASICINFO");
formgroup1.ColumnNumber = 2;
formgroup1.Width = "100%";
formgroup1.AddLabeledTextBox("RoleName", this.Resource("User", "ROLENAME"), true,true);
formgroup1.AddLabeledTextBox("Desc", this.Resource("User", "DESCRIPTION"), string.Empty,"normaltextarea", true, true, true, false);
formbuilder.Groups.Add(formgroup1);
return formbuilder;
}

public ActionResult Create()
{
return View(CreateForm());
}
In View
<% =((Dragon.Prototype1.Infrastructure.FormBuilder.jQueryFormBuilder)ViewData.Model).Display()%>

Last edited Nov 1, 2009 at 2:54 AM by tonyqus, version 2

Comments

No comments yet.