I am trying to use the new dynamic component feature released in .net 6. I have watched all the videos on youtube and done the examples. I simply cant seem to figure how to get a value back from the component. I have used the Parameters Property of the dynamic component tied together with an event, but my use case will be to have a bunch of dynamic components loaded on to the page and the submit button is part of the parent page and not the dynamic components. When submit it clicked, I just want the value from the textbox dynamic component on the parent page. Heres an example :
TextBoxComponent
@Label: <input type="text" style="margin: 5px;" @bind-value="@TextBoxValue"/> @code{ public string Label { get; set; } public string TextBoxValue { get;set; } protected override Task OnInitializedAsync() { return base.OnInitializedAsync(); }}Index Page:
@page "/"@if (type != null){<DynamicComponent Type="type" />}<button class="btn btn-primary" @onclick="SaveToDatabase">Submit</button>@code { Type type; protected async override Task OnInitializedAsync() { type = typeof(TextBoxComponent); } private void SaveToDatabase() { // get the text value of the dynamic component and insert into db }}I have tried creating an object called Appstate and assigning a string property but still I cant get the value.