0

I have a cshtml MVC Razor page, where I have a "Register" button. I want to make an onclick event with a name for example "registerFUNCTION" name, and I want to make a function called "registerFUNCTION" in cshtml.cs file. I want to write the code for registrating, but in the beginning, I don't know, how can I call and write a function in cshml.cs. Is it possible? Like:

cshtml file:

<button  onclick="registerFUNCTION" value="Register"/>

cshtml.cs file:

void registerFUNCTION(Object sender, EventArgs e)
{
    ....
}

I know that is not working, I just wondered to make like this, just only don't know the syntax. I worked in visual studio c# programming, but I need to make this in visual studio code web API c#, and it's new to me. I didn't find any answer on the internet

szaszagado
  • 21
  • 1
  • 7
  • 1
    Your trying to mix client-side code and server-side code, that will not work like that. – mxmissile Apr 03 '20 at 20:49
  • i know, that how to do that in a visual studio, where I just put some button, labels and i have onClick event, but i'm not understand, that how to do that in here, any idea? – szaszagado Apr 03 '20 at 21:11
  • The MVC razor pages is for web development, and in web applications, the JavaScript is using for that client side interactions(about onclick, valuechange events, etc.). Check the JavaScript. – Cotur Apr 03 '20 at 23:10

0 Answers0