Event driven page (VB.net)
<script runat="server" language="vb">
Sub Add(sender as object, e As EventArgs)
lblAnswer.Text = CDbl(tbxInput1.text) + CDbl(tbxInput2.text)
End Sub
Sub Subtract(sender as object, e As EventArgs)
lblAnswer.Text = CDbl(tbxInput1.text) - CDbl(tbxInput2.text)
End Sub
Sub Factor(sender as object, e As EventArgs)
lblAnswer.Text = CDbl(tbxInput1.text) * CDbl(tbxInput2.text)
End Sub
Sub Ratio(sender as object, e As EventArgs)
lblAnswer.Text = CDbl(tbxInput1.text) / CDbl(tbxInput2.text)
End Sub
</script>
<html>
<form runat="server">
<asp:textbox id="tbxInput1" runat="server" />
<asp:button id="btnAdd" runat="server" text=" + " Onclick="Add" />
<asp:button id="btnSubtract" runat="server" text=" ?"
Onclick="Subtract" />
<br/>
<asp:textbox id="tbxInput2" runat="server" />
<asp:button id="btnFactor" runat="server" text=" x " Onclick="Factor" />
<asp:button id="btnRatio" runat="server" text=" ?" Onclick="Ratio" />
<br/>
<b>Answer = <asp:Label id="lblAnswer" runat="server" /></b>
</form>
</html>
Related examples in the same category