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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:17:18+00:00 2026-05-20T16:17:18+00:00

I have a view that displays a list of comments. It does this via

  • 0

I have a view that displays a list of comments. It does this via the DisplayTemplate. All I have to do is something like @Html.DisplayFor(x => x.BlogPost.PostComments) and all the comments render appropriately.

There is a form at the bottom of the page to add a new comment. This page utilizes progressive enhancement. So if javascript is disabled then the form submits like normal, adds the comment to the database, then redirects to the action that renders the blog post. However, if javascript is available then jQuery hijacks the form’s submit and makes the post via ajax. Well because the comment markup is in a display template, I don’t know how to return it from the action method so that jQuery can drop it on the page.

I know how to do this with partial views. I would just have the action method return the right partial view and jquery would append the response to the comment container on the page.

Before I go chopping out my display template in favor of a partial view, is there a straight forward way that I’m missing to send back a display template from the controller?

Here is my action method:

    public ActionResult AddComment(PostComment postComment)
    {
        postComment.PostedDate = DateTime.Now;
        postCommentRepo.AddPostComment(postComment);
        postCommentRepo.SaveChanges();
        if (Request.IsAjaxRequest())
            return ???????
        else
            return RedirectToAction("BlogPost", new { Id = postComment.BlogPostID });
    }

When the page loads it doesn’t need to worry about it because it uses the templates in the standard way:

<div class="comments">
    @Html.DisplayFor(x => x.BlogPost.BlogPostComments)
</div>

I just want to know how I might send a single comment that utilizes the display template back to jQuery.

  • 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-20T16:17:19+00:00Added an answer on May 20, 2026 at 4:17 pm

    Does this question give you what you are looking for? Seems to indicate that you can call a HTML helper from an action.

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

Sidebar

Related Questions

I have a view that displays a list of comments. Now a comment can
I have a list view that displays a collection of items, each item has
I have created a list view that displays the names and dates of items
I have written a partial view that displays a list of rows, where some
I have a table view that displays a list that I want the user
I have a show view that displays the selected item from a list. Then
I have a view that displays a list of models. Some of the properties
Ok, currently I have a view in my android app that displays a list
Hi hoping someone can help. I have a list view that displays various textviews,editviews
In my ASP.NET MVC application I have a view that displays a list of

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.