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 6683215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:47:43+00:00 2026-05-26T04:47:43+00:00

I have an mvc3 web page that takes a url parameter representing a date,

  • 0

I have an mvc3 web page that takes a url parameter representing a date, i.e dd-MM-yyyy

public ActionResult Calendar(string startDate, string UserId, string status, bool myPage = false)

I have a partial view within the calendar view which calls an onchange event whenever a ddl is changed, representing the status parameter within the method and is also passed into the url.

My map route for the calendar view looks like this:

routes.MapRoute(
            "TimesheetCalendar", // Route name
            "Timesheet/Calendar/{startDate}/{UserId}", // URL with parameters
            new { controller = "Timesheet", action = "Calendar", UserId = UrlParameter.Optional } // Parameter defaults
        );

And my javascript onchange event (called within a contained partial view) looks like this:

<script type="text/javascript">
$(function () {
    $(".ddl").change(function () { changePage(); });
});

function changePage() {
    location.href = '@Url.Action("Calendar", "Controller", new { startDate = @ViewBag.startDate, UserId = (string)null })/' + '@ViewBag.userId' + '?status=' + $('#ControllerStatus').val() + '&myPage=@ViewBag.myPage';

}

In the calender get method in my controller, I set the Viewbag.startdate as date.ToString(dd-MM-yyyy).

It works fine, some of the time. And when I change the ddl status the page refreshed the calendar and partial view according to the status. Some of the time however (it seems whenever the week of my calendar is the current week), when I change the ddl, the browser redirects to a 404 error, and rather than the date as dd-MM-yyyy in the url, it is showing as dd/MM/yyyy and thereby completely screwing up the url.

I am new to javascript and have no idea why it would do this? I hope I have given enough info about my code. Anyone know why the string representing date would suddenly have its hyphens – changed to dashes/ ?

Any help greatly appreciated

  • 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-26T04:47:43+00:00Added an answer on May 26, 2026 at 4:47 am

    Sorry. Have just realised that the default ToString method for dates users a slash/ and that somewhere inbetween passing dates back and forth between the view and its partial view I was setting a date ToString() and not ToString("dd-MM-yyyy")

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

Sidebar

Related Questions

I'm creating a MVC3 web site, and I have place in the page where
I have added an MVC3 web application to an existing website that consists of
I have an asp.net mvc3 project, it has some reports in aspx web pages.
I have a C#.Net MVC3 web app. I am using Drop Down lists all
I have a new MVC3 application with a few legacy Web Form pages. I'm
I have a MVC 3 Razor web application that needs to allow creating and
I have develop small Asp.net MVC3 application using Telerik rad Controls with in that
I have written a little bog standard asp.net mvc3 app in vs web express
I have a variable within item.Name that contains the string It's Tuesday!. To alleviate
I have created a simple MVC3 web site and I want to limit access

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.