2016-11-11 7 views
1

DateTimePickerを動的に作成したいと考えています。私はいくつかの参考文献を見直しましたが、クラスを作成し、それを動的に作成されたTextBoxコントロール(http://www.ashishblog.com/assign-datepicker-to-runtimedynamic-textboxes-in-asp-net-using-jquery/)に割り当てることをお勧めします。 .csファイルにDateTimePickerを動的に作成したいと思います。C#でasp.netでdatetimepickerを動的に(クラスなしで)作成するには?

すなわちテキストコントロール

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

は誰が私にリンクまたはコードの行を提案してくださいことはできますか?

+1

「どのクラスもサポートしていない」とはどういう意味ですか? C#はオブジェクト指向言語なので、すべてのレベルでクラスに関係しています。 jQueryやその他のUIベースのコントロールを意味しますか? –

+0

UIベースのコントロール。つまり、TextBox、CheckBoxListコントロールを動的に作成するのと同じように、DateTimePickerを作成する方法があるかどうかです。 JQueryはありません。私は例と私の質問を編集しています。 Plzは –

+0

を提案します。 'TextBox'はクラスです。 –

答えて

0

まず

nuget

インストール・パッケージBootstrap.Datepicker

が、その後、日付ピッカーについて

<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> 
    </div> 
    <script> 
     $(function() { 
      $(document).on('focus', '.mytimepicker', function (e) { 
       $(this).datepicker({ 
        autoclose: 'true' 
       }); 
      }); 

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

詳細に沿うインストールまたは手動でダウンロードして、あなたのコードベースに貼り付けbootstrap-datepicker

関連する問題