I just want to subtract two textbox values and show it int third textbox. It is working in a simple webform but not in Masterpage & content page
This is my Master Page Code:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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>JQUERY SUBTRACT</title>
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
This is my Content page code:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
<asp:TextBox ID="num1" runat="server" name="num1"></asp:TextBox>
<asp:TextBox ID="num2" runat="server" name="num2"></asp:TextBox>
<br />
<asp:TextBox ID="subt" runat="server" name="subt" BorderStyle="None"></asp:TextBox>
</div>
<script type="text/javascript">
$(function ()
{
$("#num1, #num2").on("keydown keyup", sum);
function sum()
{
$("#subt").val(Number($("#num1").val()) - Number($("#num2").val()));
}
});
</script>
</asp:Content>
This code is working fine in single webform page but not in master & content page.
please help me in this. if u have any alternative of this then please tell me.