0

I would like to use renderpartial but I'm not so clear on the way it is used. If I just call render partial then is any model sent to that? I want to use the HTML helpers. Is there any difference between using those in renderpartial and in the main razor view?

Samantha J T Star
  • 30,952
  • 84
  • 245
  • 427

1 Answers1

0

If the view actually uses a model and you don't provide any, it just end up having a null Model object (so lots of Null Object Reference Exception).

Just go with

@{ Html.RenderPartial("_partialView", PartialViewModel); }

or:

@Html.Partial("_partialView", PartialViewModel)

The differences between the two are indicated here.

HTH, M.

Community
  • 1
  • 1
BigMike
  • 6,683
  • 1
  • 23
  • 24