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 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajeswari nathanPosted Oct 12, 2009, 6:26 AM
you can use Attribute for that Textbox
TextBox aText = new TextBox();
aText.Attributes.Add("on_keyup", "JavascritpFunctname");
kaunainbaig kaunainbaigPosted Oct 20, 2009, 12:31 AM
gsdf gdsfPosted Oct 18, 2009, 3:13 PM
But I need masterpage with menus.
What can I do?
gsdf gdsfPosted Oct 18, 2009, 2:40 PM
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>