Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a macro where I have a contact form.
Because the contact form uses Contact model I want my macro to be strongly typed.
How to make the macro to accept custom model?
This doesn't work:
@inherits Umbraco.Web.Macros.PartialViewMacroPage<MyWebsite.Models.ContactModel>
It says PartialViewMacroPage cannot be used with typed arguments
I'm using a grid and macro is inserted to the page via macro item of the grid
I don't think a model can be passed into a macro view only macro parameters/
If you want a strongly typed model in there you would need to call
@Html.Action("action", "controller")
In the macro and they work work with a strongly typed model from the returned view.
Alternatively extend PartialViewMacroPage with your model and then inherit that? as this essentially is already the model of a UmbracoViewPage
public abstract class PartialViewMacroPage : UmbracoViewPage<PartialViewMacroModel> {
Thanks.
Carl
I think I just use a standard form and macro without the model :(
Thanks anyway
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
How to use custom model in macro partial?
I have a macro where I have a contact form.
Because the contact form uses Contact model I want my macro to be strongly typed.
How to make the macro to accept custom model?
This doesn't work:
It says PartialViewMacroPage cannot be used with typed arguments
I'm using a grid and macro is inserted to the page via macro item of the grid
I don't think a model can be passed into a macro view only macro parameters/
If you want a strongly typed model in there you would need to call
In the macro and they work work with a strongly typed model from the returned view.
Alternatively extend PartialViewMacroPage with your model and then inherit that? as this essentially is already the model of a UmbracoViewPage
Thanks.
Carl
I think I just use a standard form and macro without the model :(
Thanks anyway
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.