0

I am trying to render something like razor's render partial in dotvvm master page. but found nothing from the documentation but the following:

Master Page Nesting

You can also nest a master page in another master page and so on. Just use the @masterPage directive in the master page to specify parent master page.

Basically I want to render navigation menu which will be defined in another master page in my parent master page.

Tushar
  • 481
  • 6
  • 26

1 Answers1

1

I think that you are looking for a Markup Control, see the docs for more details: https://www.dotvvm.com/docs/tutorials/control-development-markup-only-controls/2.0

In short, markup control allows you to declare custom control in a dothtml file. You can use all DotVVM features in the markup control, you'll just have to explicitly declare how data from the view model should be passed if you want to use data bindings.

A minimalist markup control may look like this:

<!-- The control must be used when data context is this view model: -->
@viewModel Full.Name.Of.MyViewModelBase

<ul class=menu>
    <li>{{value: NameOfSomething}}</li>
    <li>...</li>
</ul>

Then, the control must be registered, so DotVVM can find it:

// in DotvvmStartup

config.Markup.AddMarkupControl(tagPrefix: "cc", tagName: "MyMenu", "Views/MyMenu.dotcontrol");

After that, you can use the control anywhere you want (well, recursion works only sometimes ):

<cc:MyMenu />

You can also declare properties and then use it inside the control. It may help with reusability of the control since the view model does not have to fit. I'll leave it to the docs

exyi
  • 452
  • 3
  • 12