Addition of two numbers with the help of TextBoxes  

Addition is an arithmetic operation that represents the operation of adding numbers to a collection. It is written using the plus sign ( + ) between the terms. The result is expressed with an equals sign.

0 433 Technology | Asp.Net
Fri Dec 28 , 2018

Addition represents adding or increasing physical and abstract quantities using different kinds of objects including negative numbers, fractions, irrational numbers, vectors, decimals, functions, and matrices.

TextBox control is most important and usable web server control in This control is used to take user input in rectangular box or we can say TextBox is a place where user can input some text on web form.

In this article we will discuss Addition of two numbers with the help of two TextBoxes and result will display in Label control.

Take 2 TextBoxes one for First number, other for second number and result will show in Label control.



<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <div style="text-align:center; margin-top:20%;">
    <asp:Label ID="Label1" runat="server"></asp:Label>  
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /><br />
    <asp:Label ID="Label2" runat="server"></asp:Label>  
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /><br />
    <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click"/><br /><br />
    <asp:Label ID="Label3" runat="server"></asp:Label>


      protected void Page_Load(object sender, EventArgs e)
            Label1.Text = "Enter First Number";
            Label2.Text = "Enter Second Number";
            btnAdd.Text = "Add";
            Label3.Visible = false;
        protected void btnAdd_Click(object sender, EventArgs e)
            int first, second, result;
            first = Convert.ToInt32(TextBox1.Text);
            second = Convert.ToInt32(TextBox2.Text);
            result = first + second;
            Label3.Visible = true;
            Label3.Text = "Total is : " + result.ToString();

Subscribe & Get Regular Updates On Your E-mail