I am working with asp.net(C#). I created a razor page and want to call a function in C# using the html button click. The function performs a matching algorithm similar to the stable marriage problem. For example, when the Admin clicks on button "Button1", the function matching() in C# has to be called, which should execute the statements within the function and return the matched list in the end. I have seen some generic answers in the form but I need something more specific. Thanks in advance
As mentioned, this is a matching algorithm- to perform a two-sided matching with one sided preference. I have already tried the html "Button1_Click" solution. this is very generic and doesn't go with my code.
this is what I have done so far:
html code:
<form id="form1" runat="server">
<button type="submit" id="cmdAction" text="Button1" runat="server">
Button1
</button>
</form>
C# code:
public ActionResult OnGet()
{
if (NTUser.Role != Role.Admin)
{return RedirectToPage("/Denied");}
matching();
return RedirectToPage();
}
public void matching()
{//body}
The button I am using on the html side is "Match and Show the result"
I expect the output to be a list like an excel sheet that can be edited/deleted if need be.
Edit: I would also appreciate if someone has an idea how to do it with an enum and/or bool
razorsyntex or plain html to call theActiononController? It will be more helpfull of you update yourView's code hererunat="server") with Razor Pages. They are two different, and incompatible, frameworks. If you are using Razor Pages and want to determine which button was clicked, use named handlers:learnrazorpages.com/razor-pages/…