I want to create Dynamic Form for Add (i.e Add Employee) functionality. I can create all the control(TextBox, RadioButtonList, CheckBoxList, DropDownList) but I don't know how to create DateTime control. :(
DNN Provides readymade control(http://uxguide.dotnetnuke.com/UIPatterns/DatePicker.html) but I don't know how to create it dynamically in my code.
I have read this(http://www.ashishblog.com/assign-datepicker-to-runtimedynamic-textboxes-in-asp-net-using-jquery/) also but it doesn't work
Can anybody suggest me link or way to achieve it? It would be better it I can use DNNDateTime picker.
Here is my code: View.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="View.ascx.cs" Inherits="Customer.Modules.CustomerDemo.View" %>
<div id="div_customer" style="visibility: visible">
<asp:PlaceHolder ID="mainPlaceHolder" runat="server"></asp:PlaceHolder>
</div>
View.ascx.cs --> Page Load event
foreach (FieldsDetails item in listOfFields)
{
switch (item.FieldType)
{
case FieldTypes.Text:
TextBox textControl = new TextBox();
textControl.ID = "txt_" + item.FieldName;
textControl.Text = item.FieldValue;
textControl.TextChanged += TextControl_TextChanged; ;
mainPlaceHolder.Controls.Add(textControl);
break;
case FieldTypes.DropDown:
//code to create DropDown
break;
case FieldTypes.Checkbox:
//code to create Checkbox
break;
case FieldTypes.DateTime:
//code to create DateTime
//create TextBox control and apply class or Is there readyname DNN Control?
break;
}
}