-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathindex.html
39 lines (37 loc) · 1.25 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Electron + .NET Example</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
button {
margin-top: 10px;
}
</style>
</head>
<body>
<h1>Call .NET Method from Electron</h1>
<input type="number" id="number1" placeholder="Enter first number" />
<input type="number" id="number2" placeholder="Enter second number" />
<button id="addButton">Add Numbers</button>
<p id="result"></p>
<script>
document.getElementById('addButton').addEventListener('click', async () => {
const num1 = parseInt(document.getElementById('number1').value);
const num2 = parseInt(document.getElementById('number2').value);
const resultElement = document.getElementById('result');
try {
const result = await window.myAPI.callDotNet('Add', num1, num2);
resultElement.innerText = `Result: ${result}`;
} catch (error) {
resultElement.innerText = `Error: ${error.message}`;
}
});
</script>
</body>
</html>