Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI friends,Try the source below;The javascript i used for automatic calculation;
i want the t1,t2,t3 controls in server side for further coding.
For eg:I want this t3 value to label on button click event;

Quote:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
function nims() {

var a = parseFloat(document.form1.t1.value);
var b =parseFloat(document.form1.t2.value);
var sum = a + b;
document.form1.t3.value = sum;
}
</script>

<title> </title>
</head>
<body>
<form id="form1" runat="server">

<input type="text" value="0" name="t1" onkeyup="nims();" />
<input type="text" value="0" name="t2" onkeyup="nims();"/>
<input type="text" value="0" name="t3" />


</form>
</body>
</html>
Posted
Updated 26-Apr-12 23:11pm
v2

Can you add runat="Server" tag there?
 
Share this answer
 
Comments
Nimisha Mary John 13-Apr-12 4:37am    
The current work is in client side;
It will not work if i add runat="server" tag
Pete O'Hanlon 27-Apr-12 5:51am    
It will - it will still render client side, but it will give server access as well.
Shahin Khorshidnia 29-Apr-12 4:52am    
+5
If you want to access the controls on the server side for any calculation, you have to mark the controls as 'runat=server'.

Based on the change, you surely have to change the Javascript code too. Current implementation is based on client side html controls, but once you add the runat property to the controls, the way to access them will change. Use <%= myControl.ClientID %> to access the control on client side in JavaScript after the change.
 
Share this answer
 
v3
Comments
VJ Reddy 27-Apr-12 11:38am    
5!
Shahin Khorshidnia 29-Apr-12 4:51am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900