Search code examples
c#razorblazorrazor-pages.net-8.0

Razor page SiteContent data binding does not work


I have a razor page with .Net 8 core and i have set the rendermode to InteractiveServer,

@rendermode InteractiveServer

I am using the SectionContent with a variable to bind the value to the front end,

Initially the variable is set as empty string,

public string? result { get; set; } = "";

and it gets updated on click of a button as below,

result = $"Search Results for\"{Query}\"";

however, the value is not getting bound in the view.

<SectionContent SectionName="page-header-subtitle">
   @result
</SectionContent>

Can someone help?


Solution

  • You will have to make the outlet interactive:

    <SectionOutlet @rendermode="InteractiveServer" SectionName="page-header-subtitle" />