C#C
C#16mo ago
Qwerz

Blazor: calling a function on submit

Please someone tell me if I'm approaching this the wrong way:

when a form is submitted I want to display a modal for which I have a function "ShowModal()". I attempted to call it at the end of the HandleSubmit function appointed to the form. However, the page reloads on submit...no modal is ever shown. Example below:

c#
<EditForm . . .>
  <Button Type="ButtonType.Submit" value="Submit">Submit</Button>
</EditForm>

@code{

  void handleSubmitClick(){
    //do stuff
    openModal();
  }
  void openModal(){
    //opens the modal
  }
}


Now I can imagine this being a problem in future ventures extending the basic contact form, so I ask: how can I call a function in the chain triggered by a submit event (which reloads the page).
Was this page helpful?