Event driven page (VB.net) : Button « Asp Control « ASP.Net






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

1.Event in code behind file (VB.net)
2.asp:button: command name and arguments (VB.net)
3.Set Button text (VB.net)
4.asp:button event to change the label text (VB.net)
5.Button action Command and Parameter (VB.net)
6.Add action listener to a server Button (VB.net)
7.asp button postbackurl (C#)
8.asp button on client click (C#)
9.Button counter: click and change button label (C#)
10.Add action listener to asp Button by delegate (C#)
11.Read input and do the calculation in Button action listener (C#)
12.Button event Handler (C#)
13.onmouseover and onmouseout events
14.OnClientClick event
15.CausesValidation="False"