Okay, so on my MAIN Index view under controller Books... there is a table that holds 5 books. Then, there is a link Daily Summaries, controller DailySummary... that will take the user to the Daily Summaries Index view table for whichever book the user selected, for today's date

return View(dailySummaries.Where(x => x.Day == DateTime.Today.Date).ToList());

So the relationship is 1 book can have many Daily summaries.

Now i have implemented filtering using PredicateBuilder so the user can search the daily summaries based on date, author, etc.... but if the user wants to get back to the initial Daily Summaries Index page (based on today's date) then I created a button:

<input type="button" class="btn btn-primary top-margin" value="Clear Search" onclick="location.href='@Url.Action("Index", "DailySummaries", new { id = /*problem is here*/, area = "" })'" />

But i cannot redirect the user to the initial Index page of Daily Summaries because the Model at the top of the view is @model IEnumerable<AviationLogSummary.Models.DailySummary> so I can't do this:

<input type="button" class="btn btn-primary top-margin" value="Clear Search" onclick="location.href='@Url.Action("Index", "DailySummaries", new { id = Model.ID, area = "" })'" />

So let's say the URL for the initial Index page of Daily Summaries is http://localhost:xxxx/DailySummaries/Index/6

How do I pull that 6 off of the URL and incorporate it into my routingAttributes for my button? I have researched and found Request.QueryString, but I am unsure of how to implement that in cshtml? Also read that that is not good practice.

Any help is appreciated.

Related posts

Recent Viewed