Aspnetcore: Blazor component with <Form> submit parent page Oninit is called.

Created on 29 Jul 2019  路  2Comments  路  Source: dotnet/aspnetcore

Not sure if this is a bug or a feature of Blazor, but here it goes.

If I have a page with consumes a component which has a html Form Tag and a submit button. The parent pages OnInit is called. Which means that all components on that page potentially gets its original state (same as on page load).

My Workaround was to have the button as type button and not submit.

My question is should an underlying component with a form trigger a parent page oninit event ?

I would expect that the component itself would handle the form submit and if needed use StateHasChanged.

Any thoughts?

area-blazor question

All 2 comments

Thanks for contacting us, @KennethInfoEasy.
This is indeed expected. It's not clear what you're actually trying to do here. Feel free to provide more details, and we may be able to show you a better path.

No need to investigate further as this is expected behavior. Thank you for getting back to me so quick @mkArtakMSFT.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Trcx528 picture Trcx528  路  85Comments

kevinchalet picture kevinchalet  路  761Comments

KerolosMalak picture KerolosMalak  路  269Comments

zorthgo picture zorthgo  路  136Comments

oliverjanik picture oliverjanik  路  91Comments