View Full Version : ASP.NET textboxes

01-18-2005, 10:21 PM
I am sure this is simpler than I imagine, but I have this form I want to combine two textbox values into one textbox value somewhere later down the form. How do I incorporate the javascript to do so in my C# code? I cannot seem to figure this out. Does anyone have a simple example or solution they can share with me? Or Just guide me in the right direction?

01-19-2005, 08:37 PM
since forms in asp.net are postbacks you will need to use the onchange event of the two textboxes and then go from there. just make a couple functions that would manipulate the strings from the 1st two testboxes to make the 3rd

01-19-2005, 08:45 PM
Thanks, but after a few hours of tinkering.... I came up with this solution.

In my HTML I added this:

<script type="text/javascript">
function getID() {
document.Form1.txtbox.value = document.Form1.txtFirstName.value + " " + document.Form1.txtLastName.value;

Then in the code behind in the Page_Load I added this:

txtFirstName.Attributes.Add("onKeyUp", "getID()");
txtLastName.Attributes.Add("onKeyUp", "getID()");

This works well and there isn't a need for postback.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum