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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:27:39+00:00 2026-06-08T05:27:39+00:00

I’ve created a working MVC page which brings back a set of data that

  • 0

I’ve created a working MVC page which brings back a set of data that displays a specific report (top customers by amount spent). I’m trying to add two jQuery datepicker textboxes that will allow users to bound that report by a start and end date. It’s currently working, in that I have an HTML anchor tag with a jQuery click event bound to it, that kicks off a handler. The handler tosses the start/end date to an HttpPost ActionResult method in my controller, and it gets the updated data set.

The problem is when I try to return the data to the view (rather than returning Content(“true”)), no data is returned, and the handler gives me my OnFailure message. Is it possible to pass data to the view this way, or do I need to re-write it with a using Html.BeginForm type of approach?

Thanks so much!

Here’s the code:
(in my view)

<script type="text/javascript">
$(document).ready(function () {
    $(".datepicker").datepicker();

    $('#submit').click(function () {
        SetDateHandler($('#startdate').val(), $('#enddate').val(), "company");
    });

    function SetDateHandler(bounddate1, bounddate2, datetype) {
        $.ajax({
            //url: '/Projects/TestArray',
            url: '@Url.RouteUrl("SetBoundingDate")',
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: OnComplete,
            data: JSON.stringify({ startdate: bounddate1, enddate:bounddate2, type: datetype }),
            traditional: true,
            type: "POST",
            error: OnFail
        });

        return false;
    }
    function OnComplete(result) {
        //indow.location.href = window.location.href;
        alert("yay!");
        return true;
    }
    function OnFail(result) {
        alert('Request Failed');
        return false;
    }

});
</script>

<h2>Top Companies by Total Price for Won Quotes</h2>

<div style="float:right; width: 350px; margin: 15px;">
    <span style="float:right; margin-right: 50px;">Start Date: <input class="datepicker" id="startdate" /></span>
    <br />
    <span style="float:right; margin-right: 50px;">End Date: <input class="datepicker" id="enddate" /></span>
    <br />
    <a href="#" id="submit">Submit</a>
</div>

Custom route:
routes.MapRoute(
name: “SetBoundingDate”,
url: “AjaxSetBoundingDate”,
defaults: new { controller = “Reports”, action = “SetBoundingDates” }
);

In my Reports controller:

[HttpPost]
public ActionResult SetBoundingDates(String startdate, String enddate, String type)
{
    Schedule.Models.Reports.TopCompaniesModel Companies = new Models.Reports.TopCompaniesModel();

    ActionResult view;

    if (type == "company")
    {
        view = TopCompaniesReport(startdate, enddate);
    }
    else
    {
        view = TopContactsReport(startdate, enddate);
    }
    //return View(view);
    return Content("true");
}

Again, if you’ve read this far, I get to the bottom of my Controller method with view filled correctly, but when I try to return View, it errors, and if I return Content(“true”), it works but nothing changes on the page.

Thanks!

  • 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-08T05:27:41+00:00Added an answer on June 8, 2026 at 5:27 am

    Thanks again flem for trying to help. My approach was wrong, I eventually found I needed to switch to the razor postback method. It actually was a lot easier this way as well.

    Here’s the way I did it:

        <div style="float:right; width: 550px; margin: 15px;">
            @using (Html.BeginForm(ViewContext.RouteData.GetRequiredString("action"), "Reports", FormMethod.Post, new { id = "TheForm" }))
            {
                 <span style="float:right;">
    
                        <div style="margin-right: 50px;float:right;">Start Date: <input class="datepicker" name="startdate" id="startdate" /></div>
                        <div style="margin-right: 50px;float:right; margin-top: 5px; clear: both;">End Date: <input class="datepicker" name="enddate" id="enddate" /></div>
    
                        <input id="submit" name="submit" type="submit" value="Update" style="margin-top: 10px; clear: both;float:right;" />
    
                 </span>
                 <span style="float: left;">
                    @Html.DropDownList("DateDdl", (SelectList)ViewBag.DateDropDown)
                 </span>           
    
            }
        </div>
    

    I actually like this way much better, because as you can see I’m passing it the current controller name to be posted back. This way, I put this functionality into a shared partial view, which I can reuse on any view within the reports area.

    Hope this helps someone else!

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.