We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cant add a value and clientside event at the same time

in my view when I do this

@Html.EJ().DatePicker("STartDate").DateFormat("dd/MM/yyyy").Value(ViewBag.StartDate) it works

and when I do this

@Html.EJ().DatePicker("StartDate").DateFormat("dd/MM/yyyy").ClientSideEvents(s => s.Select("onStartDate")) it works

but when I do this

@Html.EJ().DatePicker("StartDate").DateFormat("dd/MM/yyyy").Value(ViewBag.StartDate).ClientSideEvents(s => s.Select("onStartDate"))

 I get an error Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.

what I want to do is have the date picker open with a value that I give it and if the user changes it fire the client side event is this possible



3 Replies

SN Sasikala Nagarajan Syncfusion Team September 4, 2015 12:48 PM UTC

Hi Andrew,
Thanks for contacting Syncfusion support,
In your code you are using ViewBag to get the date from controller. Once we provide the ViewBag, the statement will be dynamically dispatched. So if we use Lambda expression after the ViewBag, thelambda expression will not work.

Please refer to the below discussion:


We have two solutions to avoid this issue in our side.

Method 1:

Store ViewBag value in a variable with data type specified and then use in control value fields.


var dateValue=(string)ViewBag.StartDate;

@Html.EJ().DatePicker("StartDate1").Value(dateValue).ClientSideEvents(e => e.Change("onStartDate"))

Method 2:

Specifying theViewBagvalue, after providing the Lambda expression:


@Html.EJ().DatePicker("StartDate2").DateFormat("dd/MM/yyyy").ClientSideEvents(s => s.Select("onStartDate")).Value(ViewBag.StartDate)

Sasikala Nagarajan

AS Andrew Simpson September 7, 2015 12:54 PM UTC

Thankyou my code is working now


SN Sasikala Nagarajan Syncfusion Team September 8, 2015 04:40 AM UTC

Hi Andrew,

Thanks for the update.
Please get back to us if you need any further assitance.We will be happy to help you out.

Sasikala Nagarajan

Live Chat Icon For mobile
Up arrow icon