ASP.net and JQuery UI Datepicker

后端 未结 4 742
情歌与酒
情歌与酒 2021-01-15 21:53

Given:


Where the id = datepicker tells the javascript to attach all the datepicker code to

4条回答
  •  心在旅途
    2021-01-15 22:47

    I think it's a good practice to have a class which triggers a date picker to be created for everything that has it, such as 'js-date-picker'

    then to avoid duplication of code, you can just write the following JS once:

    $(document).ready(function() { 
        $(".js-date-picker").datepicker();
    });
    

    to get ASP.net to set a class on the textbox correctly so it uses this class, just add CssClass="js-date-picker" to the tag:

    
    

    Hope this clarifies things for you.

提交回复
热议问题