title: .net core Blazor render cshtml partial view component dynamically
body: <p>In my blazor <code>.razor</code> component I have this code...</p>
  <pre class="lang-cs prettyprint-override"><code>... stuff ...
  
  @HistoricDeck
  
  ... stuff ...
  
  @code
  {
      protected GameDataModel GameData { get; set; }
  
      protected RenderFragment HistoricDeck { get; set; }
  
      protected async Task LoadDeck(FriendSupportModel deck, DeckType type)
      {
          HistoricDeck = builder =&gt;
          {
              var deckFragment = new SupportDeck() {
                  GameData = GameData,
                  AssetList = GameData.AssetList,
                  Deck = deck.normalDeck,
                  Type = DeckType.Standalone,
              };
              builder.OpenElement(0, &quot;div&quot;);
              builder.AddAttribute(1, &quot;SupportDeck&quot;, deckFragment);
              builder.CloseElement();
          };
          StateHasChanged();
      }
  }
  </code></pre>
  <p>LoadDeck is called by an <code>@onclick=</code> event on the page, I wish to dynamically render a new SupportDeck() into the page. How do I do this? The code below is non-functional (breakpoints in SupportDeck.cshtml are not hit, for example).</p>
  <p>SupportDeck.cshtml.cs:</p>
  <pre class="lang-cs prettyprint-override"><code>public class SupportDeck
  {
      public FriendServantListModel Deck { get; set; }
      public DeckType Type { get; set; }
      public GameDataModel GameData { get; set; }
      public AssetList AssetList { get; set; }
  }
  </code></pre>
  <p>SupportDeck.cshtml:</p>
  <pre><code>@model Project.Views.Shared.SupportDeck
  ... stuff ...
  @if (Model.Deck != null) {
  &lt;p&gt;Hello world&lt;/p&gt;
  }
  ... stuff ...
  </code></pre>
  <p>Here is how I would normally render this view fragment in a non-blazor page:</p>
  <pre class="lang-cs prettyprint-override"><code>@{
      await Html.RenderPartialAsync(&quot;SupportDeck&quot;, new SupportDeck
      {
          Deck = Model.FriendSupport.normalDeck,
          Type = DeckType.Normal,
          GameData = Model.GameData,
          AssetList = Model.AssetList
      });
  }
  </code></pre>