.Net Core Razor Pages - Partial View Help

Hello, I’m pretty new to .Net Core, EF Core & Razor pages.

I have a form which uses posts to a razor page. The page model has three bound properties, two of which are EF Models (I use inheritance to only bind safe properties) and one is just a string:

 [BindProperty]
 public Models.BaseEvent _Event { get; set; }

 [BindProperty]
 [Display(Name = "Venue Search")]
 public string _VenueSearch { get; set; }

 [BindProperty]
 public Models.Venue _Venue { get; set; }

I then have a form, used to create an event. When adding information about the event, they can either choose an existing venue, using the venue search, or add a new one. _VenueSearch is bound only to automatically re-populate the form if there is an error. I use jquery to perform autocomplete on the field.

However, I’m trying to put the form into a partial, but I have no idea how to pass in _Event, _VenueSearch & _Venue?

Here is my form (Sorry made it a link - can’t seem to post code without it formatting weirdly):

How would I put this in a partial so that I still have access to the two models and string (_Event, _Venue & _VenueSearch. I haven’t included the javascript autocomplete code as its irrelevant to this post.

I want to use a partial as both me create/edit pages will use the same form, so I don’t see the point of duplication.

Thanks in advance for any help

Matt

.NET Foundation Website | Blog | Projects | Code of Conduct