© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y 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:

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

@code{

  void handleSubmitClick(){
    //do stuff
    openModal();
  }
  void openModal(){
    //opens the modal
  }
}
<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).
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ HAVING TROUBLE CALLING A FUNCTION
C#CC# / help
2y ago
Calling a function from a string.
C#CC# / help
4y ago