Import codes for reuse in Asp.Net MVC

Asked

Viewed 55 times

0

Img 1

Img 2

I made this image class 1, and I wanted to reuse, import the whole class to be in the marked place of image 2, so I didn’t have to change on all pages whenever I want to update something.

1 answer

0


Okay, come on. First on Image 1, you created a PartialView, and what is a PartialView?

A Partial View or Partial View translated into poor English, is a View where your code is reusable in several other places.

How to use a Partial View?

@Html.Partial("NomeDaSuaView", model)

Being the model in the above example an additional parameter.

More information: https://docs.microsoft.com/pt-br/aspnet/core/mvc/views/partial?view=aspnetcore-2.2

  • 1

    Just what I was looking for, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.