Nanji Mange Nanji Mange - 1 year ago 75
ASP.NET (C#) Question

How to create datetimepicker dynamically(without class) in with C#?

I want to create

dynamically. I have reviewed few reference but all suggest to create class and assign it to
control which has created dynamically( I want to create
dynamically in .cs file without support of any class.

i.e Text Control

TextBox textControl = new TextBox();
textControl.ID = "txt_ID";
textControl.Text = "";
textControl.AutoPostBack = true;
textControl.TextChanged += TextControl_TextChanged; ;

Can anybody please suggest me link or lines of code?

Answer Source

First install or download manually and paste it in your codebase


Install-Package Bootstrap.Datepicker

then follow along

 <link href="Content/bootstrap.min.css" rel="stylesheet" />
    <link href="Content/bootstrap-datepicker.css" rel="stylesheet" />
    <script src="Scripts/jquery-1.10.2.js"></script>
    <script src="Scripts/bootstrap.js"></script>
    <script src="Scripts/bootstrap-datepicker.min.js"></script>
    <div id="add">
        <input type="text" name="datepicker " value=" " class="form-control mytimepicker" />
        <button id="addMore">addMore</button>
        $(function () {
            $(document).on('focus', '.mytimepicker', function (e) {
                    autoclose: 'true'

            $('#addMore').click(function (e) {
                $('#add').append('<input type="text" name="datepicker " value=" " class="form-control mytimepicker" />');

more info about datepicker bootstrap-datepicker

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download