Passing a date between two pages

Ok, so I have an MVC webapp. I’ve tried for hours to pass one simple variable from TransactionsDatePicker.cshtml to Transactions display.

I have an input with an id of ‘transactionlookupdate’. I want to intercept it (input type is date).

I’ve managed to append the date to the link like this:

document.getElementById("buttoncontinue").addEventListener("click", function () {
    dateSelected = document.getElementById("transactionlookupdate").value;
    document.location.href = 'TransactionsDisplay' + '/' + dateSelected;

Now, what do I do in TransactionsDisplay (where I want to get the date) to store it in usable variable?!

So far I’ve tried like a 100 different ways, one that got me the closest was:

(top of TransactionsDisplay.cshtml)

    ViewBag.Title = "TransactionsDisplay";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var dateSelected = Request.Url.Segments.Last();

and awful try at populating alert with dateSelected:

    function myFunction() {

Any help would be appreciated!

1 thought on “Passing a date between two pages”

Leave a Comment