Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7933741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:25:10+00:00 2026-06-03T21:25:10+00:00

i know there are a lot questions like this but i really cant get

  • 0

i know there are a lot questions like this but i really cant get the explanations on the answers… here is my view…

<script type="text/javascript" language="javascript">
$(function () {
    $(".datepicker").datepicker({ onSelect: function (dateText, inst) { },
        altField: ".alternate"
    });

});
</script>

@model IEnumerable<CormanReservation.Models.Reservation>
@{
ViewBag.Title = "Index";
}

<h5>
    Select a date and see reservations...</h5>
<div>
    <div class="datepicker">
    </div>
    &nbsp;<input name="dateInput" type="text" class="alternate" />
</div>

i want to get the value of the input text… there’s already a value in my input text because the datepicker passes its value on it… what i cant do is to pass it to my controller… here is my controller:

  private CormantReservationEntities db = new CormantReservationEntities();
    public ActionResult Index(string dateInput )
    {
        DateTime date = Convert.ToDateTime(dateInput);
        var reservations = db.Reservations.Where(r=>r.Date==date).Include(r => r.Employee).Include(r => r.Room).OrderByDescending(r => r.Date);
        return View(reservations.ToList());
    }

i am trying to list in my home page the reservations made during the date the user selected in my calender in my home page….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:25:11+00:00Added an answer on June 3, 2026 at 9:25 pm

    I don’t see a Form tag in your View…or are you not showing the whole view? hard to tell.. but to post to your controller you should either send the value to the controller via an ajax call or post a model. In your case, your model is an IEnumerable<CormanReservation.Models.Reservation> and your input is a date selector and doesn’t look like it is bound to your ViewModel. At what point are you posting the date back to the server? Do you have a form with submit button or do you have an ajax call that you aren’t showing?

    Here is an example of an Ajax request that could be called to pass in your date

    $(function () {
        $(".datepicker").onselect(function{
              searchByDate();
            })
        });
    
    });
    
    function searchbyDate() {
       var myDate = document.getElementById("myDatePicker");
    
        $.ajax({
            url: "/Home/Search/",
            dataType: "json",
            cache: false,
            type: 'POST', 
            data: { dateInput: myDate.value },
            success: function (result) {
                if(result.Success) {
                   // do something with result.Data which is your list of returned records
                }
            }
        });
    }
    

    Your datepicker control needs something to reference it by

    <input id="myDatePicker" name="dateInput" type="text" class="alternate" />
    

    Your action could then look something like this

    private CormantReservationEntities db = new CormantReservationEntities();
    
    public JsonResult Search(string dateInput) {
        DateTime date = Convert.ToDateTime(dateInput);
        var reservations = db.Reservations.Where(r=>r.Date==date).Include(r => r.Employee).Include(r => r.Room).OrderByDescending(r => r.Date);
        return View(reservations.ToList());
        return Json(new {Success = true, Data = reservations.ToList()}, JsonRequestBehaviour.AllowGet());
    }
    

    Update

    If you want to make this a standard post where you post data and return a view then you need to make changes similar to this.

    Create a ViewModel

    public class ReservationSearchViewModel {
        public List<Reservation> Reservations { get; set; }
        public DateTime SelectedDate { get; set; }
    }
    

    Modify your controller actions to initially load the page and then be able to post data return the View back with data

    public ActionResult Index() {
        var model = new ReservationSearchViewModel();
        model.reservations = new List<Reservation>();
        return View(model);
    }
    
    [HttpPost]
    public ActionResult Index(ReservationSearchViewModel model) {
        if(ModelState.IsValid)    
        var reservations = db.Reservations.Where(r => r.Date = model.SelectedDate).Include(r => r.Employee).Include(r => r.Room).OrderByDescending(r => r.Date);
        }
        return View(model)
    }
    

    Modify your view so that you have a form to post to the Index HttpPost action

    @model CormanReservation.Models.ReservationSearchViewModel
    
    <h5>Select a date and see reservations...</h5>
    @using (Html.BeginForm()) {
        @Html.ValidationSummary(true)
        @Html.EditorFor(model => model.SelectedDate)
        @Html.EditorFor(model => model.Reservations) // this may need to change to a table or grid to accomodate your data
        <input type="submit" value="Search" />
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are a lot of questions around on this subject, but I've
I know there a lot of similar questions to this, but I didn't find
I know there's a lot of questions about this but I've been struggling with
ok, I know there are a lot of questions here about this, that are
I know that there are a lot of questions and answers exactly about this
I know that there are a lot of questions like this on the web
I know there are a lot of questions similar to mine, but I actually
Okay I know there are a lot of questions about this and a lot
I know there are a lot of similar questions on SF, but I think
I know there are a lot of such questions on stackoverflow but I couldn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.