0

I tried to find a clear answer, but could not. Where does the helper method such as Html.RenderAction() and Html.Partial() are executed? at the server or the client side? Is the razor code, executed locally?

If on the server, is there a client-side alternative?

Thanks

Plexis Plexis
  • 302
  • 2
  • 12

1 Answers1

1

Razor runs on the server, and generates HTML. This HTML is then sent to the client.

If you want to render or change HTML on the client, you'll need to do so using JavaScript. You could for example serialize your model into JSON and store that in a JavaScript variable:

<script>
    var myModel = @JsonConvert.SerializeObject(someObject);
</script>

Then you can access myModel from JavaScript to do whatever you want, for example bind it to a clientside MVC framework such as Angular or Ember.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272