c# - ASP.NET MVC. How render a Partial with no model (like create view) -
i render partial this:
@html.partial("_mypartial")
however partial need typed object, instance: mypartial.cshtml :
@model myapplication.models.myclass (...)
but render on view without initialized model, "create" view.
create views bound model, initialized empty.
what tried:
@html.partial("_mypartial")
main view model passed partial , throws incompatible types error.
@html.partial("_mypartial", null)
throws same error.
@html.partial("_mypartial", new myclass())
initializes view default values. don't want pre initialized view.
in "create" view, no model passed view, view bound model. render partial in "create" view. must no bound initialized model instance. must initialized empty.
you have write code accept model type in view:
@model myapplication.models.myclass
so compulsory have pass model in view.
if don't wants use model remove code accept model
Comments
Post a Comment