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 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

Related Questions

I'm working with a dynamic DOM here, and have called the jQuery UI datepicker
I have a datepicker control setup using the JQuery UI, I am also using
I have a jquery datepicker which is renders the current date by default as
i have one jquery ui datepicker working fine. I am now adding a second
I have a view based project working with a UINavigationController. The RootViewController performs operations
I have this code in the view to display datepicker for input type.. Problem
I have a view containing a segmented controller and a UIDatePicker that only shows
I have the jQuery datepicker working, but I need to be able to select
I have used jquery datepicker in my .aspx page. The control is working fine.
I have the jQuery UI Datepicker and the bassistance.de validation plugin working except for

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.