DatePicker error with Core 5.0

1 Answer 237 Views
DateRangePicker
Miro
Top achievements
Rank 1
Iron
Iron
Miro asked on 03 Jun 2021, 03:44 AM

I have attached the code plus the error message.

 

kendo support us in 2 ways to declare control in razor view.
- @(
Html.Kendo().DatePicker
)
- @{
Html.Kendo().DatePicker()
.Render();
}

 

but with the second if I add HtmlAttribute with 4 attribute inside, it will get error.
 ex: @{
Html.Kendo().DatePicker()
.HtmlAttribute(new {a="id1", b ="id2", c="id3", d="id4"})
.Render();
}
Miro
Top achievements
Rank 1
Iron
Iron
commented on 03 Jun 2021, 03:45 AM

The error attached in DatePicker2.jpeg based on case 2.

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 07 Jun 2021, 03:02 PM

Hi Miro,

Thank you for the shared screenshots.

The error message from the first screenshot is displayed because the value of the parameter "compareType" is reserved in HTML. You could escape it with "\\" as follows:

 

@{
    Html.Kendo().DatePicker()
        .Name("monthpicker2")
        .Start(CalendarView.Year)
        .Depth(CalendarView.Year)
        .Format("MMMM yyyy")
        .Value("Novemeber 2011")
        .DateInput()
        .HtmlAttributes(new { id = Guid.NewGuid().ToString(), compareType = "\\>" })
    .Render();
}

Regarding the example below, I have tested it locally and it appears to be working properly at my end:

 

@{
    Html.Kendo().DatePicker()
        .Name("monthpicker2")
        .Start(CalendarView.Year)
        .Depth(CalendarView.Year)
        .Format("MMMM yyyy")
        .Value("Novemeber 2011")
        .DateInput()
        .HtmlAttributes(new { a = "id1", b = "id2", c = "id3", d = "id4" })
    .Render();
}

 

Would you please review these examples and let me know if the issue is resolved at your end?

 

Regards, Mihaela Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Miro
Top achievements
Rank 1
Iron
Iron
commented on 08 Jun 2021, 11:55 AM

Thanks Mihaela for your help. It works :)
Tags
DateRangePicker
Asked by
Miro
Top achievements
Rank 1
Iron
Iron
Answers by
Mihaela
Telerik team
Share this question
or