Click here to Skip to main content
16,015,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
i want to populate data from database in a text box after press tab key.
the thing is like that....
where i am having 3 textboxes.In textbox 1 i am inserting 2, and In textbox 2 i am inserting 2. And I want do addition.Now i have a procedure where i am doing addition.and i want to fetch addition value into the textbox 3 after pressing tabkey.

if someone know please share the knowledge.
thanks avi....
Posted
Comments
Sunny_Kumar_ 21-Jun-12 0:05am    
please clarify what actually you want to do. You want the addition of two text box's value in third one or you want to fetch something from database. what have you tried yet to achieve this??

1 solution

In the aspx page write
ASP.NET
<asp:textbox id="TextBox1" runat="server" autopostback="true" ontextchanged="TextBox1_TextChanged" xmlns:asp="#unknown" />
<asp:textbox id="TextBox2" runat="server" autopostback="true" ontextchanged="TextBox1_TextChanged" xmlns:asp="#unknown" />
<asp:textbox id="TextBox3" runat="server" xmlns:asp="#unknown" />

In Code behind page
C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
   if(TextBox1.Text.Length != 0 && TextBox2.Text.Length != 0)
   {
        TextBox3.Text = (Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text)).ToString();
   } 
}

Try above code
I have added a event name OnTextChanged which will fire when u change the text of the textbox.
 
Share this answer
 
Comments
Member 12427267 12-May-16 8:35am    
its not working

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