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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:57:23+00:00 2026-05-27T23:57:23+00:00

I have a web page that shows a table of data. My page has

  • 0

I have a web page that shows a table of data. My page has jQuery on some elements such that when the elements change an Ajax call is made to the database and the element is updated in the database.

I also have a need to sometime completely refresh the data grid. It would seem to me there are two ways of doing this:

1) Use Ajax to call my controller action, check if is an Ajax request using Request.IsAjaxRequest, return HTML.Partial to the javascript that called the Ajax and have that update the HTML. I have this method 90% working already.

Previous stackoverflow question

2) Use the following:

<div id="#thingy">@Html.Action("Detail", new { ac, me })</div>  
$('#thingy').load("@Server.JavaScriptStringEncode(Url.Action("Detail", new { ac, me }))"); 

Now I am still trying to get the first method to work but also looking at the second method and thinking it looks a lot easier.

I want to write code that works but also code that conforms most to the MVC way of doing things. With this in mind. Which might be the best method? One thing that concerns me is the @Server.Java… code. I have never seen this before and I am wondering how this is handled with MVC, does all the normal security get applied?

  • 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-27T23:57:23+00:00Added an answer on May 27, 2026 at 11:57 pm

    melissa,

    I’d almost definitely stick with a partialview (and @RenderPartial()) IF the model in the view is the same as that in the partialview, otherwise you could opt for the @RenderAction() helper to invoke data refreshes across your view where the base data type varies significantly from the base view data type.

    You’ll know from your app which approach is best suited to the use case in question, but definitely the RenderPartial() would be the approach to major on, where ajax updates are required at a later point in the piece to update the html in the div.

    [edit] – here’s how i would see this set out in practice:

    // this is a div contained within the main Detail.cshtml view
    <div id="#thingy">@Html.RenderPartial("_Detail", Model)</div>
    

    this would automatically on 1st pass populate the div from the Model against a partialview called _Detail.cshtml. Subsequently, you would invoke your ajax to target this same div (#thingy) via an action which returned the partialview and model as per the above.

    i.e.:

    public ActionResult Detail(string ac, string me) {     
       vm.AdminDetails = _link.Detail(ac + me).ToList();      
       if (Request.IsAjaxRequest())         
          return PartialView("_Detail", vm);     
       return View(vm); 
    }
    

    Hope this makes sense.

    good luck

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

Sidebar

Related Questions

I have a webpage that retrieves data (via ajax/php) and shows it in an
I have web forms page that has 2 controls. A gridview and an associated
I have a web page that prompts for user input via DropDownLists in some
I am using Web-Harvest to do some web page scraping. I have a table
I have a simple web app with a table that shows an array of
I have one web page MyWebPage.aspx which while loading has to show data from
I have a table that stores the page hits on a web application, storing
new on rails and using windows for now,, i have web page that user
I have a web page that whenever your in a text-field, if you hit
I have a web page that I display in a WPF WebBrowser control within

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.