Cannot get TextChanged event to fire

Using Visual Studio, vb.net:  I need to have a text box fill in dynamically without page postback either of two other text boxes change in value.  I have tried using the change event in code-behind for the text boxes and I've tried using javascript in the HTML, all to no avail.  Any suggestions or points to help would be welcome!!
aibarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
If you're trying to use the TextChanged event then that will cause a postback, but only if you have AutoPostBack set to true on the control. Otherwise the event is cached until the next time a Postback is triggered.

You should be able to use javascript on the client. Can you give us an idea of exactly what needs to happen and when ?
0
aibarAuthor Commented:
I have three text boxes.  When text box #1 or #2  changes in value, I need text box #3 to change in value.  So simple, and I knew how to do it before in regular ASP, but for the life of me cannot do it now?!  Thank you for any help!
0
enwhyseeCommented:
How about something like this? Here, when either textboxes 1 and 2 change in value, textbox 3 will become the concatenation of their values. This doesn't use a postback at all.


<script language="javascript">
function onTBChange()
{
   var textbox3ID="<% Response.Write(TextBox3.ClientID); %>";
   document.getElementById(textbox3ID).value =
       document.getElementById('TextBox1').value + document.getElementById('TextBox2').value;
}
</script>    
   
    <input type="text" ID="TextBox1" onchange="onTBChange()" onblur="onTBChange()"  onkeydown="onTBChange()" />
    <input type="text" ID="TextBox2" onchange="onTBChange()" onblur="onTBChange()"  onkeydown="onTBChange()"/>
    <asp:TextBox ID="TextBox3" runat="server" />
   

Note that only TextBox3 is an ASP.NET textbox, and only its value will get submitted with the form post for cleanliness (since I am assuming you don't need the values of textboxes 1 & 2 later.)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

aibarAuthor Commented:
Perfect!  Works perfectly and I've learned a lot from this little snippet you gave. Thanks!
0
enwhyseeCommented:
Glad it was of help! :)

I just re-read my post, and my comment in the last sentence was of course wrong. The values of TextBox1 & TextBox2 will also be submitted along with the rest of the form data when you do a postback, since they're both input elements (even if they aren't marked as runat="server"). But for practical intents and purposes it doesn't matter a whole lot.

0
aibarAuthor Commented:
One more note - I got an error when I first ran it that I had an illegal character.  Removing the first ";" from this line:
 var textbox3ID="<% Response.Write(TextBox3.ClientID); %>";
solved the problem.  Thanks again!
0
enwhyseeCommented:
I see, it must be because you're using VBScript instead of C#. In C# the ; would be required, but in VB it is invalid.
Take care!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

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.