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

  • Home
  • SEARCH
  • 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 346451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:10:42+00:00 2026-05-12T11:10:42+00:00

I have a DatePicker working on a View which also has a ViewModel associated

  • 0

I have a DatePicker working on a View which also has a ViewModel associated with it.
When I execute the Post action back to the controller the ViewModel is instantiated again and some of the values are not available from the View.

The Controller Action is:

    public ActionResult Search()
    {
        ProjectSearchViewModel viewModel = 
            new ProjectSearchViewModel(
                DateTime.Today.AddMonths(-1), 
                DateTime.Today.AddDays(1));

        return View(viewModel);
    }

  [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Search(ProjectSearchViewModel viewModel)
    {
        try
        {
            //Always returns a value from UI
            DateTime startDate = viewModel.StartDate; 
            //NEVER returns a Value from UI
            DateTime endDate = viewModel.EndDate; 

…..

The View markup is:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/TabbedViewMasterPage.master"
Inherits="System.Web.Mvc.ViewPage<Reactivity.Web.Models.ProjectSearchViewModel>"
%>

…

 <label for="StartDate">
        Start Date:
    </label>
    <% Html.jQuery().DatePicker()
            .Name("StartDate")
            .AllowMonthChange(true)
            .AllowYearChange(true)
            .ShowOn(DatePickerShowOn.Focus)
            .ShowOtherMonths(true)
            .Value(ViewData.Model.StartDate)
            .Render(); %>
    <br />
    <label for="EndDate">
        End Date:
    </label>
    <% Html.jQuery().DatePicker()
            .Name("EndDate")
            .AllowMonthChange(true)
            .AllowYearChange(true)
            .ShowOn(DatePickerShowOn.Focus)
            .ShowOtherMonths(true)
            .Value(ViewData.Model.EndDate)
            .Render(); %>
    <br />
    <input type="submit" value="Search" />

The DatePicker (two instances on View) work fine.

How do I ensure the ViewModel fields (viewModel.EndDate) are returned populated to the Controller Action? Or is this an issue with having two (MVC) DatePickers on the form?

Many thanks
Brian

  • 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-05-12T11:10:42+00:00Added an answer on May 12, 2026 at 11:10 am

    Ok, there are two issues here:

    1. I´m new to MVC etc., and had put the Telerik MVC Extensions in to my project which to you jQuery guys will know that the code above is Telerik CTP. Sorry about that.

    2. The issue in the end was rather interesting. The code above was not handling date localisation correctly such that dates that were entered in the datepicker with browser localisation set to NON-US English were being handled as US format such that when I selected 28/07/2009 (a correct en-UK format) either Telerik wrapper for the datepicker control would not pass it throught or something in the pipeline was rejecting it. The result was that any dates beyond the 12th of the month were not being returned.

    I hope this helps someone else along the way.

    Brian

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 162k
  • Answers 162k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer While you can certainly create a custom constructor like the… May 12, 2026 at 11:57 am
  • Editorial Team
    Editorial Team added an answer Instead of breaching security this way you can make the… May 12, 2026 at 11:57 am
  • Editorial Team
    Editorial Team added an answer The && and || operators are defined to evaluate lazily,… May 12, 2026 at 11:57 am

Related Questions

So I did some reading of the related questions and had some interesting stuff
I need to have a click to edit element on a page, that will
I've been tasked with implementing a Date/Time selector for several areas of our web
How will you approach to implement a WYSIWYG document editor in WPF? This editor
I'm using the jQuery DatePicker control for the first time. I've got it working

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.