Pass value from one textbox to anothet

Hello Guys! I have a combo box which has two values namely Allowence and Accommodation. When Allowence is selected, the focus is shifted to a text box to enter the value. Once the value is entered, I want that value to be in another text box. How can I do that and under which control should I write the code. Something like this.
txtemphraallowence = txtemphracost
Who is Participating?
tetorvikConnect With a Mentor Commented:
i would do it with javascript:
on page_load attach onblur attribute on textbox where you want to copy from and attribute value is a javascript statement to copy the entered value.
No postbacks required...

                String.Format("javascript:document.getElementById('{0}').value=document.getElementById('{1}').value;", txt1.ClientID, txt2.ClientID));

Open in new window

i'd use

txtemphraallowence.text = txtemphracost.text

put this on the textchangeed event of txtemphracost. If you're using webforms make sure autopostback is set to true.
Anurag ThakurTechnical ManagerCommented:
i will ask a question before i suggest a solution
why - what is the need to copy the text from one text box to another?
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

preethamonlineAuthor Commented:
Well ragi, i have a drop down list with 2 values. One is allowence and the other is accomodation.
I have 2 text boxes. One for allowence and the other called ctc.
So when a value is entered in allowence text box i also want it to appear in the ctc box, so that it helps calculating the CTC (Cost to company) of the employee.

I hope its not confusing. I have attached a sample screenshot of what i'm trying to achieve.
Anurag ThakurTechnical ManagerCommented:
the solution provided by tetorvik should do the trick for you
preethamonlineAuthor Commented:
Thanks guys.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.