Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have 3 TextBox (TextBox1, TextBox2, TextBox3)
If I give the velue in TextBox1 and TextBox2 then the sum result is displayed in TextBox3. I am doing this in javascript code. Codes are working nicely

But if I add them inside a Teb Container then it does not works.

I cant understand what is the problem?
Can any one to help me.
[I am using Asp.Net]

Thanks in advance
Rashed

My Code is like this

<script type="text/javascript">
function ChangeAmountBooking() {

var SigningMoney = parseFloat(document.getElementById('TextBox1').value);
if (document.getElementById('TextBox1').value == '') {
SigningMoney=0;
}
var HouseRentPerpose = parseFloat(document.getElementById('TextBox2').value)
if (document.getElementById('TextBox2').value == '') {
HouseRentPerpose = 0;
}



document.getElementById('TextBox3').value = SigningMoney+HouseRentPerpose;

}
</script>

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<br />
<br />
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0"
Width="850px">
<cc1:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
<ContentTemplate>


<table>
<tr>
<td>
TextBox1</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
TextBox2</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
TextBox3</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
</table>



</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
<ContentTemplate>

</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>



CS Page Code

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox1.Attributes.Add("onblur", "javascript:return ChangeAmountBooking()");
TextBox2.Attributes.Add("onblur", "javascript:return ChangeAmountBooking()");

}
}
Posted

1 solution

I think Ur problem is with ID of text box.
when u use textbox in tab the id is generated dynamically

there r 2 way to overcome this.

1.
run ur project in browser and view source file and see what id is assign to it and replace it with ur id in javascript
for ex:
document.getElementById('TextBox1').value
should change with
document.getElementById('TabContainer1_TabPanel1_TextBox1').value

2. u can use
]]>
or
]]>

according to ur project

I hope This will help u.
 
Share this answer
 
Comments
[no name] 30-Jan-12 23:21pm    
Thanks it is working.. now....
CRDave1988 31-Jan-12 3:02am    
welcome

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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