Try this it would solve your problem in both the cases, you can either do by pressing the button or by changing the value of the DropDownList.
protected void Unnamed1_SelectedIndexChanged(object sender, EventArgs e)
{ TextBox1.Text = DropDownList1.SelectedValue; }
The above event is intended to populate the Salary text box, Replace with your logic.
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type = "text/javascript"> function CalculateSum() {
var txt1 = document.getElementById("<%=TextBox1.ClientID %>");
var txt2 = document.getElementById("<%=TextBox2.ClientID %>");
var txt3 = document.getElementById("<%=TextBox3.ClientID %>");
var txt4 = document.getElementById("<%=TextBox4.ClientID %>");
var txt5 = document.getElementById("<%=TextBox5.ClientID %>");
var txt6 = document.getElementById("<%=TextBox6.ClientID %>");
txt6.value = parseInt(txt1.value) - parseInt(txt2.value) - parseInt(txt3.value) - parseInt(txt4.value) - parseInt(txt5.value);
return false; } window.onload = function () {
CalculateSum(); } </script> </head>
<body style="font-family: Arial; font-size: 10pt">
<form id="form1" runat="server">
<asp:DropDownList runat="server" ID="DropDownList1" AutoPostBack="true"
OnSelectedIndexChanged="Unnamed1_SelectedIndexChanged">
<asp:ListItem Text=" Select " Value="0"></asp:ListItem>
<asp:ListItem Text="Employee1" Value="6000"></asp:ListItem>
<asp:ListItem Text="Employee2" Value="7000"></asp:ListItem>
<asp:ListItem Text="Employee3" Value="8000"></asp:ListItem>
</asp:DropDownList> <br />
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="true"></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Calculate Sum" OnClientClick = "return CalculateSum()" />
</form> </body>