Hey all,
I hit a confusion point recently when working with KendoUI controls inside of forms.
Lets say I have today's date in my ViewBag (e.g. ViewBag.startDate exists with a valid date).
I've generated this control with the ASP.NET MVC kendo UI:
@Html.Kendo().DatePicker().Name("startDate").Value(@ViewBag.startDate).Format("d")
On the initial form post, this works fine.
Lets say I submit a form, causing a postback that changes the value of "startDate" in my ViewBag (on the server side).
If I print the ViewBag's startDate and then below it, generate my DatePicker control in the same way fashioned above, I get 2 different dates. The printed one is whatever the server side changed it to, and the Kendo control has the first ViewBag.startDate.
As soon as I generate my control like this (e.g. without the "@" in front of ViewBag):
@Html.Kendo().DatePicker().Name("startDate").Value(ViewBag.startDate).Format("d")
everything seems to be fine between form posts.
This confused me for a good long while yesterday. Does anyone know why this is? I'm thinking it's some Razor knowledge that I may be lacking, but I'd think if it worked with or without the "@" on any attempt, it would work on every attempt.
Thanks for any help on why this is!
-Sig
I hit a confusion point recently when working with KendoUI controls inside of forms.
Lets say I have today's date in my ViewBag (e.g. ViewBag.startDate exists with a valid date).
I've generated this control with the ASP.NET MVC kendo UI:
@Html.Kendo().DatePicker().Name("startDate").Value(@ViewBag.startDate).Format("d")
On the initial form post, this works fine.
Lets say I submit a form, causing a postback that changes the value of "startDate" in my ViewBag (on the server side).
If I print the ViewBag's startDate and then below it, generate my DatePicker control in the same way fashioned above, I get 2 different dates. The printed one is whatever the server side changed it to, and the Kendo control has the first ViewBag.startDate.
As soon as I generate my control like this (e.g. without the "@" in front of ViewBag):
@Html.Kendo().DatePicker().Name("startDate").Value(ViewBag.startDate).Format("d")
everything seems to be fine between form posts.
This confused me for a good long while yesterday. Does anyone know why this is? I'm thinking it's some Razor knowledge that I may be lacking, but I'd think if it worked with or without the "@" on any attempt, it would work on every attempt.
Thanks for any help on why this is!
-Sig