The tag helper for a DatePickerFor and the Razor Tag for a DatePickerFor generate different ID for their respective control.
Tag Razor: @(Html.Kendo().DatePickerFor(m => m.testObject.TestSousObject))
Generate : <input id="testObject_TestSousObject" name="testObject.TestSousObject" type="text" value="" /><script>kendo.syncReady(function(){jQuery("#testObject_TestSousObject").kendoDatePicker({"format":"yyyy-MM-dd"});});</script>
Where the Id = testObject_TestSousObject (with an underscore)
---------------------------
<kendo-datepicker name="DateComparaisonExamensImagerieAnterieurs" for="ExamensImagerieMedicale.DateComparaisonExamensImagerieAnterieurs" />
Generate : <input id="testObject.TestSousObject" name="testObject.TestSousObject" type="text" value="" /><script>kendo.syncReady(function(){jQuery("#testObject\\.TestSousObject").kendoDatePicker({});});</script>
Where the Id = testObject.TestSousObject (with a dot)
Is it something new with .NET Core compared to MVC? In my mind, both method should generate the same Code and Ids.
Note: I tested it with a entirely new .NET core 2.1 project
I was trying to get DatePickerFor work on a Kendo Grid Popup editor with no luck. I've already spent countless hours first with the DropDownListFor (https://www.telerik.com/forums/dropdownlistfor-events-in-razor-pages) which still doesn't work and now with DatePickerFor. Any help is much appreciated.
I have the DatePickerFor in a Kendo Grid Popup Template.
Grid:
.DataSource(dataSource => dataSource
.Custom()
.Transport(t => {
t.Read(r => r.Action("Cases", "CaseList", new { handler = "GetCases" }).Type(HttpVerbs.Post).Data("sendAntiForgeryToken"));
t.Create(r => r.Action("Cases", "CaseList", new { handler = "AddCase" }).Type(HttpVerbs.Post).Data("sendAntiForgeryToken"));
})
Razor Page:
public JsonResult OnPostAddCase([DataSourceRequest] DataSourceRequest request, CaseModel newCase)
Popup Template:
@(Html.Kendo().DatePickerFor(model => model.LetterDate)
.HtmlAttributes(new { style = "width:150px; font-size:14px" })
)
Model:
[DataType(DataType.Date, ErrorMessage ="Letter Date is required")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
[Display(Name ="LetterDate")]
public DateTime LetterDate { get; set; }
FormData:
LetterDate: Tue Jul 31 2018 13:04:15 GMT-0400 (Eastern Daylight Time)
Error: The value 'Tue Jul 31 2018 13:04:15 GMT-0400 (Eastern Daylight Time)' is not valid for LetterDate.
I have tried several solutions like setting up the culture, changing the formats but nothing seems to work.
The only option that I'm left with is intercepting the date before submit. But before I do that I would like to know why it is so hard to get the basic functionality work with kendo controls. This is so frustrating.
Hi,
I have 2 date pickers-
<div class=""><kendo-datepicker name="Input.ReviewStartDateTime" start="CalendarView.Month" depth="CalendarView.Year" format="yyyy/MM/dd" value="DateTime.Now" on-change="endChange"/> </div>
<div><kendo-datepicker name="Input.ReviewEndDateTime" start="CalendarView.Month" depth="CalendarView.Year" format="yyyy/MM/dd" value="DateTime.Now" /></div>
I am trying to change the value of Input.ReviewEndDateTime picker to + 60 days on change Input.ReviewStartDateTime picker -
function endChange() {
var startDatePicker = $("#Input.ReviewStartDateTime").data("kendoDatePicker"),
startDate = this.value();
console.log(startDate);
if (startDate) {
var endDate = new Date(startDate.getMonth() + 2);
var endatepicker = $("#Input.ReviewEndDateTime").data("kendoDatePicker");
endatepicker.value(startDate);
endatepicker.trigger("change");
}
}
but I get the following error-
Uncaught TypeError: Cannot read property 'value' of undefined
How can I change the date picker to 60 dates after theselected date from Input.ReviewStartDateTime
like this: .Footer("Today - #=kendo.toString(data, 'd') #")
see also sample here https://demos.telerik.com/aspnet-core/datepicker/template
Is there a simple way to change the background color of the Month/Year view?
Thanks.
-------------------------------------------------------------------------------------------------------------
<telerik:RadDatePicker RenderMode="Lightweight" ID="FromScreeningDatePicker" runat="server" Width="120px"
ClientEvents-OnDateSelected="FromDateSelected"
Calendar-CalendarTableStyle-BackColor="White"
Calendar-TitleStyle-BackColor="White"
MinDate='<%# Convert.ToDateTime("01/01/1900")%>' MaxDate='<%# Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"))%>'
DbSelectedDate='<%# startDate %>' FocusedDate="01/01/2016">
</telerik:RadDatePicker>
The DateInput server side wrapper does not appear to work with nullable DateTimes. In the below code, if 'TaxDate' is a nullable DateTime when the page is rendered the control will always display 'month/day/year' (as it does when the value is null) even if the value being passed to it isn't null.
I tried setting the .value() property on the control but it does not accept nullable DateTimes.
@(Html.Kendo().DateInput()
.Name("TaxDate")
.HtmlAttributes(new { style = "width:100%;", @class = "autoSelectText" })
From the demo page it looks as if null is a supported state, does the server side wrapper not support it?
Thanks,
Brian
The structure is
1. RadGrid
2. MasterTableView
3. EditFormSettings
4. Form Template
5. Then tables/rows/cells containing labels, textboxes, etc.
From code behind I can access all the asp and telerik items in the tables and retrieve any data for further use in my application by using the following code:
If e.CommandName = RadGrid.UpdateCommandName Then
If TypeOf e.Item Is GridEditFormItem Then
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim theClient As TextBox = DirectCast(item.FindControl("txtClient"), TextBox)
Dim theOrder As TextBox = DirectCast(item.FindControl("txtOrder"), TextBox)
Dim theRadDateOrder As RadDatePicker = DirectCast(item.FindControl("RadDatePickerOrderDate"), RadDatePicker)
etc.
I now have the value from the dbSelectedDate:
Dim theDateOrderDate As DateTime = theRadDateOrder.DbSelectedDate
Dim theDateOrderMonth As String = theDateOrderDate.ToString("MMMM")
Dim theDateOrderDay As String = theDateOrderDate.Day
And I now have a month and I have a day broke out.
Now within the form template is an asp:textbox that I want to update/insert/place the month value into. I also have a RadNumericTextBox that I want to update/insert/place the day value into.
What I want to do is update the month and day on the form when the date is selected with the RadDatePicker.
All the above was figured out by searching the internet and putting the pieces together.
I have not been able to find even a starting point on my question, it may be in the above code, but I do not see it yet.
My question is how do I do this from code behind as I cannot access the controls directly as they are within the Form Template?
Thank you for your time. Dale