txtCost = new TextBox();
txtCost.ID = "txt" + dtjCostCenter.Rows[i]["int_CostCenterId"].ToString();
txtCost.MaxLength =12;
//txtCost.Text = dtjCostCenter.Rows[i]["int_CostCenterName"].ToString();
phcosts.Controls.Add(new LiteralControl("
phcosts.Controls.Add(txtCost);
AjaxControlToolkit.FilteredTextBoxExtender ftbx = new AjaxControlToolkit.FilteredTextBoxExtender();
ftbx.ID="ftb" + dtjCostCenter.Rows[i]["int_CostCenterId"].ToString();
ftbx.ValidChars = "1234567890.";
ftbx.TargetControlID = "txt" + dtjCostCenter.Rows[i]["int_CostCenterId"].ToString();
ftbx.FilterType = AjaxControlToolkit.FilterTypes.
about 5 textboxes are created . now the thing is that i want to calculate auto sum of every textbox on keyup event and place that in total label. i have performed this thing with the non dynamic textboxes with non dynamic name
like this with javascript function being called on keyup
script language="javascript">
function sum() {
var mySum = 0;
var value1 = parseInt(document.getElementById("TextBox1").value);
var value2 = parseInt(document.getElementById("TextBox2").value);
var value3 = parseInt(document.getElementById("TextBox3").value);
if (value1 > 0) {
mySum = mySum + value1
}
if (value2 > 0) {
mySum = mySum + value2
}
if (value3 > 0) {
mySum = mySum + value3
}
document.getElementById("TextBox4").value = mySum
}
now how would i invoke keyup in my c# code to invoke the sum method.
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsForums
Top experts
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajeswari nathan97 reputationPosted Oct 12, 2009, 2:26 AM EDT
you can use Attribute for that Textbox
TextBox aText = new TextBox();
aText.Attributes.Add("on_keyup", "JavascritpFunctname");
gsdf gdsf4 reputationPosted Oct 18, 2009, 10:40 AM EDT
I simlply cannot fill the textbox2.text with the value of textbox1.text on textbox1 keyup event.
This is the web page. Could you help me?
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript">
function sum() {
var mySum = 0;
var value1 = parseInt(document.getElementById("TextBox1").value);
document.getElementById("TextBox2").value = value1
}
script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>title>
head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" on_keyup="sum();">asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server">asp:TextBox>
div>
form>
body>
html>
gsdf gdsf4 reputationPosted Oct 18, 2009, 11:13 AM EDT
But I need masterpage with menus.
What can I do?
kaunainbaig kaunainbaig113 reputationPosted Oct 19, 2009, 8:31 PM EDT