ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
How to pass datepicker value to popup controller action
Title:
B
I
{code}
?
I have a DatePicker in my view and I'd like to have its value sent back to the controller (either as a string or a DateTime value) when clicking on a grid row button which will open a popup. Here's the definition of the DatePicker: @(Html.Awe().DatePicker("weekStartDate").DayFunc("dayf").Value(DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek)) I'm am getting the row ID in the controller on it's own, but I wasn't sure how to send weekStartDate's value back as well. I was thinking something like this, where 'weekStartDate' is the name of the DatePicker: function popupFunc(record) { return '<button type="button" class="awe-btn o-pad" onclick="awe.open(\'buttonPopup\', {params:{ id: ' + record.ID + ', weekOf: ' + record.WeekStartDate + ' }}, event)"> View Data </button>'; } I've now added weekStartDate in my row model, but when I send it back to the popup controller, instead of 04/17/22 going to the controller, it's getting a value of "0.0106951871657754
Save Changes
Cancel
Sean Davidson
asked at 20 Apr 2022
Since you have `record.ID`, you can use it to get the whole `record` from your data storage and and get the `date` from there, that would be the standard way of doing this. As for the date value, depends on the json serializer (if you're on MVC5 or ASP.net Core), and how you are binding it in the action (I haven't seen your action with the `DateTime` parameter), you can read more about it here: https://www.newtonsoft.com/json/help/html/datesinjson.htm https://stackoverflow.com/questions/726334/asp-net-mvc-jsonresult-date-format
at 21 Apr 2022
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK