N
N
nordwind20132018-11-18 15:11:34
JavaScript
nordwind2013, 2018-11-18 15:11:34

What would you recommend for dynamic rendering of html in an ASP.NET MVC application?

Here's the deal. Razor must be used. With an async request, we get one of three statuses. And depending on this status, you need to change the content of the block without a full page refresh. React requires a complete abandonment of the Razor engine, as far as I understand it. Summing up, what to use to painlessly dynamically change the contents of the modal window elegantly? PS. I am a backend developer far from the new front trends. Please help, preferably with code example. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2018-11-18
@nordwind2013

You can't do a single page on razor, because razor is server-side rendering. You can not use React, but you can't do without js. With Ajax, request a partial view and insert the result into the modal window block.
In code it will look like this

$.ajax({
  type: "POST",
  url: window.baseUrl + "Controller/Action",
  data: params,
  success: function (result) {
    if (result) {
      $(".modal").html(result);
    }
  })
  
public ActionResult Action(IncomingParameters params)
{
  var model = Anything(params);
  return PartialView("Action", model);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question