Saturday, 1 March 2014

Add Two Numbers and Show Result Dynamically using Java Script & Asp Controls

Addition of Two Nos using Asp Controls

Ans:-
Default.aspx:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddWthAspCntrl.aspx.cs" Inherits="AddWthAspCntrl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Addition of Two Nos using Asp Controls</title>
    <script type="text/javascript" language="javascript">
         function Addition(val) {
             var num1 = parseInt(document.getElementById("txtSal").value);
             var num2 = parseInt(document.getElementById("txtComm").value);

             var result = num1 + num2;
             document.getElementById("txtTotSal").value = result;
         }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <div>
  <table>
<tr><td colspan='3' align="center"><b>Get Individual Employee Details</b></td></tr>
<tr><td>Sal</td><td>:</td><td><asp:TextBox ID="txtSal" onkeyup="Addition(1)" value="0" runat="server"></asp:TextBox></td></tr>
<tr><td>Commission</td><td>:</td><td><asp:TextBox ID="txtComm" onkeyup="Addition(2)" value="0" runat="server"></asp:TextBox></td></tr>
<tr><td>Total Salary</td><td>:</td><td><asp:TextBox ID="txtTotSal" onkeyup="Addition(3)" value="0" runat="server"></asp:TextBox></td></tr>

</table>
    </div>
    </center>
    </form>
</body>
</html>

No comments:

Post a Comment