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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:22:38+00:00 2026-05-27T02:22:38+00:00

I am having difficulty rendering a partial view using the MVC3 razor engine. When

  • 0

I am having difficulty rendering a partial view using the MVC3 razor engine.

When I select a ToDate, the jQuery UI datepicker will ajax POST by sending a JSON string as data.

ControllerView.cshtml:

to_date ({
    onSelect: function (selectedDate, inst) {
       // Some code here to construct JSON
       $.ajax ({
           // Appropriate attributes
           url: 'Controller',
           data: '{ FromDate: "' + data.FromDate + '", ToDate: "' + data.ToDate + '" }'
       });
    }
});

<div id="picker">
                <label for="FromDate">From: </label>
                <input type="text" id="FromDate" />
                <label for="ToDate">To: </label>
                <input type="text" id="ToDate" />
</div> <!-- END picker -->
<div id="Day">
    <!-- ****Where partial view should be rendered**** -->
</div>

This will be received by the controller(Controller.cs):

[HttpPost]
public ActionResult Controller (DatePicker Dates)
{
    if (ModelState.IsValid)
    {
        // Save IList returned from query
        IList<Obj> JsonObj = Model.query(Dates);

        return PartialView("_PartialView", JsonObj);
    }
    return View();
 }

What should be my next steps? I created a _PartialView.cshtml file, but I haven’t been able to render the view. Also, is my approach correct if I want the view to be rendered asynchronously?

Thanks for the help!

  • 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-27T02:22:39+00:00Added an answer on May 27, 2026 at 2:22 am

    Simply add a function to run on success of the ajax call:

    to_date ({
        onSelect: function (selectedDate, inst) {
           // Some code here to construct JSON
           $.ajax ({
               // Appropriate attributes
               url: 'Controller',
               data: '{ FromDate: "' + data.FromDate + '", 
                        ToDate: "' + data.ToDate + '" }'
               success: function (result) {
                   // when the AJAX succeeds replace the Day tag with the new view
                   $('#Day').html(result);
               }
           });
        }
    });
    

    You should probably also handle when the request errors by assigning a function to error:. See the jQuery.ajax() documentation for more details on both success and error.

    A bit of advice – I would highly recommend calling your action result something other than Controller. I’m not sure if you will get the model state for this call since its an AJAX call so you might want to double check that part. I would also recommend you change your action result to take in both values by name. Something like this:

    [HttpPost]
    public ActionResult RenderDatePartial(Date fromDate, Date toDate)
    {
        var dates = new List<Date> { fromDate, toDate };
    
        // Save IList returned from query
        var jsonObj = Model.query(dates);
    
        return PartialView("_DatePartial", jsonObj);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() To
I am having difficulty using a thirdparty library registration function to register a callback.
I'm having difficulty using MooseX::Declare properly when calling BUILDARGS. I'm trying to create an
I'm having difficulty debugging triggers in Oracle. Currently I'm using Oracle's Sql Developer tool.
I'm having difficulty with a php script using copy() on a shared remote host.
I'm using Devise to set up user authentication, but I'm having difficulty getting users
I am having difficulty writing a Stored Procedure that will query a list of
i am having difficulty making my jquery functions operate within wordpress. can anyone help
Hi I am having difficulty changing some attributes in jquery mobile dynamically for some
I'm having difficulty populating the second iframe on this page: http://www.licf.ronaldboadi.com/Movieshop/ Whenever you select

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.