DatePicker shows empty textbox

Sep 25, 2012 at 11:42 AM

Hi i have added the datepicker to my view but i just cant get the datepicker to show, when i use firebug i get no errors, but the textbox is empty

i have 2 date controls

      @{ var DT = Html.DateTimeFor(model => model.Arrangements_Dato, DateTime.Now, dateInCalendar: true); }
                @DT.DateCalendar(
                    inLine: false,
                    calendarOptions: new CalendarOptions
                        {
                            ChangeYear = true,
                            ChangeMonth = true

                        })
                @Html.Label("Tilmeldings frist")
                @Html.DateTimeFor(model => model.Tilmeldings_Frist, DateTime.Now).Date(useTextBoxForYear: false)

the last dateTimeFor shows 3 dropdownboxes with information the first one is empty.

 

I have followed the instructions in the documentation, googled quite a lot but i just can get it to work.

All the js files are loaded to the page.

 

Can anybody tell me what i'm oing wrong?

 

Coordinator
Sep 25, 2012 at 2:23 PM
Edited Sep 25, 2012 at 2:23 PM

Also if you set useTextBoxForYear to false, if you have not provided a min date and a max date through the DateRangeAttribute, the Date input will use a textbox for years because it doesn't know the year interval to be shown in the drop down: either use a calendar, or add min-max infos.

You can see an empty dropdown if you provided incoherent constraints for a the date, that is constraints that cannot be satisfied by any date.

Sep 26, 2012 at 9:20 AM

Hi frankabbruzzese

thanks for your reply, maby i wasent clear in my question.

I want a datetime picker to show up when the conrtrol gets focus.

in firebug i can se the js files are loaded:

GET jquery-ui-1.8.20.min.js 200 OK
GET jquery-1.7.1.js 200 OK GET MVCControlToolkit.Controls-2.2.5.js 200 OK
GET MVCControlToolkit.Controls.Core-2.2.5.js 200 OK
GET MvcControlToolkit.Bindings-2.2.5.js 200 OK
GET MVCControlToolkit.....Datetime-2.2.0.js 200 OK
GET MVCControlToolkit.Controls.Grid-2.2.0.js 200 OK
GET MVCControlToolkit....ols.Items-2.2.0.js 200 OK 

My control looks like this

     @{ var DT = Html.DateTimeFor(model => model.Arrangements_Dato, DateTime.Now, dateInCalendar: true); }
                @DT.DateCalendar(
                    inLine: false,
                    calendarOptions: new CalendarOptions
                        {
                            ChangeYear = true,
                            ChangeMonth = true
                            
                        })
And the properties in the model looks like this:
        [DateRange(RangeAction = RangeAction.Verify,SMaximum = "2014-1-1", SMinimum = "2012-1-1")]
        public System.DateTime Arrangements_Dato { get; set; }

        [DateRange( RangeAction = RangeAction.Verify,SMaximum = "2014-1-1", SMinimum = "2012-1-1")]
        public System.DateTime Tilmeldings_Frist { get; set; }

i tried adding using statements to the view .. still no Datepicker shows up 

@using MVCControlsToolkit.Controls.Bindings
@using MVCControlsToolkit.Core;
@using MVCControlsToolkit.Controls;

Firebug reports no errors but the datepicker dosen't show up. I have to have missed something, but what?

 reguards

 

Jacob

Coordinator
Sep 26, 2012 at 12:52 PM
Edited Sep 26, 2012 at 1:08 PM

it appears that jquery is loaded after jquery ui ...this is wrong. TRY TO INVERT THE ORDER OF FILE INCLUSIONS. MoreoverMVCControlToolkit.Controls-2.2.5.js includes also all other files below it except the one with the bindings suffix that is needed only if you use knockout...but after all knockout stuffs. If you use knockout just include knockout-all.min that contains everything. So you need just two files from the toolkit: MVCControlToolkit.Controls-2.2.5.js (better the minimized version) and knockout-all.min.js

Sep 26, 2012 at 1:12 PM

Thanks,

I'm using twitter bootstrap and in the _layout file all scripts are added in the buttom, after moving the script to the top of the page and loading jquery first then the datepicker shows up just as it should.

 

THANKS for your help.