'Can i link c# and html normally
Hello every1 I am both new to this site and html so i wanna ask Can i do something like that
<link href="index.cs">
then use functions If possible how ??
I want to use functions that i declare in my c sharp file fro a button like i dont know
<button id="button-test" onclick="helloworld()">click</button>
and i ll have a function in c sharp named helloworld like
void helloworld()
{
return;
}
Thnx for ur answers
Solution 1:[1]
You can use javascript functions or use asp.net.
You can call the function in controller class using ajax like this
$("#buttonId").click(function (e) {
e.preventDefault();
$.ajax({
url: "/Controller/MethodName/{parameter}"
});
});
Solution 2:[2]
Solution 3:[3]
Take a look at using Blazor or Blazor WASM:
https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor
You can use C# client side.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rangarajan |
| Solution 2 | Meysam Gheysaryan |
| Solution 3 | Dave |
