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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cant add a value and clientside event at the same time

Thread ID:





120132 Sep 3,2015 11:45 AM UTC Sep 8,2015 04:40 AM UTC ASP.NET MVC 3
Tags: DatePicker
Andrew Simpson
Asked On September 3, 2015 11:45 AM UTC

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



Sasikala Nagarajan [Syncfusion]
Replied On 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

Andrew Simpson
Replied On September 7, 2015 12:54 PM UTC

Thankyou my code is working now


Sasikala Nagarajan [Syncfusion]
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon