Hey reidar,
You don't have to do the postback thing. You can use some javascript
to achieve the same result.
Say you have three textboxes:
txtFirst,txtSecond,txtSum
To get txtSum to be calculated do the following:
In the aspx html code add the following function
<script language=javascript>
function check(){
if(parseInt(document.getElementById('txtFirst').va lue,10)!="NaN" &&
parseInt(document.getElementById('txtSecond').valu e,10)!="NaN"){
document.getElementById('txtSum').value =
parseInt(document.getElementById('txtFirst').value ,10) +
parseInt(document.getElementById('txtSecond').valu e,10)
}
}
</script>
This is basically some javascript that calculate the sum of the first
two textboxes and stores the result in the third. The 10 argument to
parseInt is not redundant ... if you have a number starting with 0 in
either of the text boxes the javascript engine will think it is an
octal number
Then in your code behind do this:
If Not IsPostBack Then
txtFirst.Attributes.Add("onChange", "check()")
txtSecond.Attributes.Add("onChange", "check()")
End If
On Thu, 30 Nov 2006 19:49:41 +0100, "reidarT" <re****@eivon.nowrote:
>I have 3 fields in an aspx page. The 3. field should be the sum of field A
and field B
I use OnTextChanged to calculate the sum in field3.
At the same time I want to insert the content of theese 3 fields into a row
in a table.
The problem is that I need 'postback is true' on the textfields to get an
immediate calculation and then the insert action is triggered.
reidarT
--
Bits.Bytes.
http://bytes.thinkersroom.com