Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP.NET textboxes

    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?
    slyfox2099
    slyfox2099@yahoo.com

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,062
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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;
    }
    </script>

    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.
    slyfox2099
    slyfox2099@yahoo.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •