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

  • Home
  • SEARCH
  • 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 540709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:16:06+00:00 2026-05-13T10:16:06+00:00

I have a bunch of code in my old Web Forms app I’m migrating

  • 0

I have a bunch of code in my old Web Forms app I’m migrating to MVC. There are sections of various pages that need to have HTML generated by the view and then regenerated by an AJAX call. A lot of this HTML is pretty complex, so it really helps to keep all of the html generation in one spot (preferrably a template).

My question is, is there a better approach to this? Should I be using partial views or something? How would that translate into the WebService call? Is there something more efficient I could be doing?

Basically this is what I’m doing now (this is a really basic, crappy, example so I apologize):

In Pseudo-code:

The Markup

<!--- some html here -->
<div id="myContent">
  <%=StaticMethods.GetContent()%>
</div>
<button id="btnUpdate">Update</button>
<!--- some html here -->

The AJAX Javascripty stuff

$(document).ready(function() {
   $('#btnUpdate').click(function() {
      $.ajax({
         url:'MyService.asmx/MyWebServiceMethod',
         /*crap here*/
         success: function(result, status, code) {
            $('#myContent').html(result);
         }
      });
   });
});

The Static Method

public static class StaticMethods {
   public static string GetContent() {
      var sb = new StringBuilder();
      var somethings = GetSomeRandomThings(); 
      //just an example. it's normally much more complex.
      foreach(var something in somethings) {
          sb.AppendFormat("<li>{0}</li>",something.Name);
      }
   }
}

MyWebService

public string MyWebServiceMethod() {
    return StaticMethods.GetContent();
}
  • 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-13T10:16:06+00:00Added an answer on May 13, 2026 at 10:16 am

    You can use partial views. But remember that you must pass the data to the partial view. If your partial view is used everywhere it could be complex.

    If you want something more independent, you can use the MVC Future’s “RenderAction()” to make a partial view act like a call to a regular action. So the “partial view” does not have a dependency to the current action being rendered.

    See the difference here: http://blogs.intesoft.net/post/2009/02/renderaction-versus-renderpartial-aspnet-mvc.aspx

    Personally, I would use RenderAction() for the initial rendering of the page. The AJAX calls to update the panel would point to the same action of the RenderAction call.

    Mike

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

Sidebar

Related Questions

I have an Excel file that has a bunch of VBA and macro code
I have a bunch of old classic ASP pages, many of which show database
In a bunch o' places in my code, I have something like this: public
I have a bunch of files that I need to be able to transport
I have a bunch of latitude/longitude pairs that map to known x/y coordinates on
I have a bunch of .NET frameworks installed on my machine. I know that
I have a bunch of perfmon files that have captured information over a period
I have a bunch (hundreds) of files that are supposed to have Unix line
I'm developing my C# 3.5 ASP.NET MVC web app, same as I do all
Does Java and/or Spring have the concept of properties? I have bunch of domain

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.