Freelance Jobs
Showing posts with label Common Handler. Show all posts
Showing posts with label Common Handler. Show all posts

Use Common Handler in ASP.NET

HOW TO PERFORM MATHEMATICAL OPERATION WITH THE HELP OF COMMON HANDLER.

CODE IN THE DEFAULT.ASPX PAGE:-




Enter the first digit
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

Enter the second digit
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

Sum of two digits
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>


<asp:Button ID="Button1" runat="server" Text="Addition" OnClick="Button1_Click">

<asp:Button ID="Button2" runat="server" Text="Subtraction" OnClick="Button1_Click">

<asp:Button ID="Button3" runat="server" Text="Division"
OnClick="Button1_Click"/>

<asp:Button ID="Button4" runat="server" Text="Multiplication" OnClick="Button1_Click"/>





WRITE CODE IN THE DEFAULT.ASPX.CS PAGE:-


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default14 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
if (sender == Button1)
{
TextBox3.Text = Convert.ToString(Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text));
}
else if (sender == Button2)
{
TextBox3.Text = Convert.ToString(Convert.ToInt32(TextBox1.Text) - Convert.ToInt32(TextBox2.Text));
}
else if (sender == Button3)
{
TextBox3.Text = Convert.ToString(Convert.ToInt32(TextBox1.Text) / Convert.ToInt32(TextBox2.Text));
}
else
{
TextBox3.Text = Convert.ToString(Convert.ToInt32(TextBox1.Text) * Convert.ToInt32(TextBox2.Text));
}
}
}

;;

ONLINE JOBS