Reputation:
I´m a C# beginner and I want to code a calculator with C# and blazor but I dont know how. My HTML is already finished, but I dont know how the blazor interface works Here is my HTML: Can anyone say to me how I have to start with that?
@page "/calculator"
<PageTitle>Calculator</PageTitle>
<h1>Calculator</h1>
<div class="display">
<p id="output">0</p>
<div class="first-row">
<button id="r1-1">C</button>
<button id="r1-3">%</button>
<button id="r1-4">/</button>
</div>
<div class="second-row">
<button id="r2-1" >7</button>
<button id="r2-2" >8</button>
<button id="r2-3" >9</button>
<button id="r2-4" >x</button>
</div>
<div class="third-row">
<button id="r3-1" >4</button>
<button id="r3-2" >5</button>
<button id="r3-3" >6</button>
<button id="r3-4" >-</button>
</div>
<div class="fourth-row">
<button id="r4-1" >1</button>
<button id="r4-2" >2</button>
<button id="r4-3" >3</button>
<button id="r4-4" >+</button>
</div>
<div class="fifth-row">
<button id="r5-1" >0</button>
<button id="r5-2" >.</button>
<button id="r5-3" >=</button>
</div>
</div>
@code {
}
Upvotes: 0
Views: 1360
Reputation: 171
For blazor buttons you'd add the onclick
function.
for example:
<button @onclick="() => SomeFunction(5)" id="r5-3">5</button>
@code
{
public void SomeFunction(int number)
{
Console.WriteLine(number);
}
}
Upvotes: 2