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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:07:45+00:00 2026-05-13T02:07:45+00:00

I am currently working on some prototypes for a web site I am wanting

  • 0

I am currently working on some prototypes for a web site I am wanting to create. Part of the web site is going to be pretty heavy with javascript. Right now I am learning the jquery and ASP.Net MVC framework combo.

The issue I am having is where I should be forming the html generated for ajax requests. For example on page load I want to load a bulleted list called #subject_list based on what project is being loaded (i.e. navigated to /Project/Manage/3, project id is 3). From the way I see it (and I’ve learned both ways) I can form the

  • elements two ways:

    1) Create a JSON object on the server with the data for each object the list is representing, and on the client form the <li> string for each item in the JSON object and append it to the #subject_list’s html.

    2) Create the <li> elements on the server (using partial views or strings built from data) and return the html directly to jquery, then have jquery put that html into the #subject_list.

    Now it seems like method 2 would be better performance wise, as it keeps the client from having to do the string manipulation and puts the task on the server (which is run from compiled c# code rather than interpreted javascript).

    However, I can’t seem to figure out how to detect errors reliably with the 2nd method. For example, if the database connection failed, query failed, meteor destroys the planet, etc… I want the ability to return an error and display that error in a modal dialog. Unless I am looking at things wrong (which is possible), it seems that if I want to use the 2nd method, I am coding my javascript to expect html and thus don’t have the option to detect if an error message occurred.

    So what is the best way to form html when using asp.net and jquery?

    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-05-13T02:07:46+00:00Added an answer on May 13, 2026 at 2:07 am

      I think the 2 method is the way to go, but just like you said, if you return text/html there is no parameter to tell what is the current state of the request (ok/error), but there is one approach that require you to do a little hack on the ViewEngine and it will let you render partial Views to String format, that way you can return a JSON structure with the state along with a piece of HTML(the partial view).

         return Json(new { 
            result = "success", 
            timestamp = DateTime.UtcNow, 
            html = this.RenderToString("View", Model) 
          });
      

      You can take a look at it here.

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

    Sidebar

    Related Questions

    I am currently working on some Ajax heavy code and I am wondering how
    Some background I'm currently working on a mobile site so I keep switching user
    I'm currently working with some data using Javascript that is in the form of
    I am currently working on some syntax highlighting in Javascript. To match strings, I
    I'm currently working on some code based on John Resig - Simple JavaScript Inheritance
    I'm currently working on some web services for a client of ours. Before we
    I'm currently working on some coding for a hotel booking widget and am using
    I am currently working with some users that do not have the .NET Framework
    I'm currently working through some exercises in a c++ book, which uses text based
    I am currently working on some simple custom allocators in c++ which generally works

    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.