C
C#10mo ago
leleco

❔ Blazor - Component button with different event depending on the page that call it

Hi, I have a component that has 4 buttons (Open, Save, Clear, Run), and this component is used in every page of the app. The "Run" button though, needs to trigger a specific event for each page it's clicked on. What's the best way to do it? I've been researching about EventCallback but I'm not sure if this is the correct approach for this situation. Thanks!
3 Replies
mg
mg10mo ago
Event handlers are the correct approach. Add an Action or Func<Task> (if async) parameter to the component that gets invoked whenever the run button is clicked Then wherever you use it in your app you hook the desired method up to the handler
leleco
leleco10mo ago
Was looking on how to use Event Handlers and could make it work! Thanks @mg
Accord
Accord10mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.